|
|
|
|
@ -160,11 +160,26 @@ func TestNormalizeYAMLScalars(t *testing.T) {
|
|
|
|
|
input: map[string]any{"value": 1.0},
|
|
|
|
|
expect: map[string]any{"value": int64(1)},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "max safe integer float becomes integer",
|
|
|
|
|
input: map[string]any{"value": float64(maxSafeYAMLInteger)},
|
|
|
|
|
expect: map[string]any{"value": int64(maxSafeYAMLInteger)},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "unsafe integer floats stay floats",
|
|
|
|
|
input: map[string]any{"value": aboveSafeInteger},
|
|
|
|
|
expect: map[string]any{"value": aboveSafeInteger},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "safe negative integer floats become integers",
|
|
|
|
|
input: map[string]any{"value": -float64(maxSafeYAMLInteger)},
|
|
|
|
|
expect: map[string]any{"value": -int64(maxSafeYAMLInteger)},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "unsafe negative integer floats stay floats",
|
|
|
|
|
input: map[string]any{"value": -aboveSafeInteger},
|
|
|
|
|
expect: map[string]any{"value": -aboveSafeInteger},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "map keys and nested values are normalized",
|
|
|
|
|
input: map[any]any{
|
|
|
|
|
@ -189,6 +204,11 @@ func TestNormalizeYAMLScalars(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestNormalizeYAMLMapKey(t *testing.T) {
|
|
|
|
|
assert.Equal(t, int64(1), normalizeYAMLMapKey(float64(1)))
|
|
|
|
|
assert.Equal(t, "[1 key]", normalizeYAMLMapKey([]any{float64(1), "key"}))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This test to check a function provided by sprig is due to a change in a
|
|
|
|
|
// dependency of sprig. mergo in v0.3.9 changed the way it merges and only does
|
|
|
|
|
// public fields (i.e. those starting with a capital letter). This test, from
|
|
|
|
|
|