Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/fixture/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func FixTabsOrDie(in typed.YAMLObject) typed.YAMLObject {
break
}
if !bytes.HasPrefix(line, prefix) {
panic(fmt.Errorf("line %d doesn't start with expected number (%d) of tabs: %v", i, len(prefix), line))
panic(fmt.Errorf("line %d doesn't start with expected number (%d) of tabs: %v", i, len(prefix), string(line)))
}
lines[i] = line[len(prefix):]
}
Expand Down
57 changes: 56 additions & 1 deletion merge/default_keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ var bookParser = func() *typed.Parser {
map:
fields:
- name: page
default: 2
default: 2.0
type:
scalar: numeric
- name: line
Expand Down Expand Up @@ -322,6 +322,61 @@ func TestDefaultKeysNested(t *testing.T) {
),
},
},
"apply_integer_key_with_float_default": {
Ops: []Operation{
Apply{
Manager: "default",
APIVersion: "v1",
Object: `
book:
- sentences:
- text: blah
`,
},
Apply{
Manager: "default",
APIVersion: "v1",
Object: `
book:
- sentences:
- text: blah
page: 2
`,
},
},
APIVersion: "v1",
Object: `
book:
- sentences:
- text: blah
page: 2
`,
Managed: fieldpath.ManagedFields{
"default": fieldpath.NewVersionedSet(
_NS(
_P(
"book", _KBF("chapter", 1, "section", "A"),
),
_P(
"book", _KBF("chapter", 1, "section", "A"),
"sentences", _KBF("page", 2, "line", 3),
),
_P(
"book", _KBF("chapter", 1, "section", "A"),
"sentences", _KBF("page", 2, "line", 3),
"text",
),
_P(
"book", _KBF("chapter", 1, "section", "A"),
"sentences", _KBF("page", 2, "line", 3),
"page",
),
),
"v1",
false,
),
},
},
}

for name, test := range tests {
Expand Down
2 changes: 1 addition & 1 deletion typed/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func validateScalar(t *schema.Scalar, v value.Value, prefix string) (errs Valida
case schema.Numeric:
if !v.IsFloat() && !v.IsInt() {
// TODO: should the schema separate int and float?
return errorf("%vexpected numeric (int or float), got %T", prefix, v)
return errorf("%vexpected numeric (int or float), got %T", prefix, v.Unstructured())
}
case schema.String:
if !v.IsString() {
Expand Down