Skip to content

Commit 462c545

Browse files
mvo5achilleas-k
authored andcommitted
Revert "Reapply "buildconfig: disable tests for undecoded keys for now""
This reverts commit f2c16ad.
1 parent b75d03b commit 462c545

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

bib/internal/buildconfig/config.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,15 @@ func decodeTomlBuildConfig(r io.Reader, what string) (*externalBlueprint.Bluepri
6262
dec := toml.NewDecoder(r)
6363

6464
var conf externalBlueprint.Blueprint
65-
_, err := dec.Decode(&conf)
65+
metadata, err := dec.Decode(&conf)
6666
if err != nil {
6767
return nil, fmt.Errorf("cannot decode %q: %w", what, err)
6868
}
6969

70+
if len(metadata.Undecoded()) > 0 {
71+
return nil, fmt.Errorf("cannot decode %q: unknown keys found: %v", what, metadata.Undecoded())
72+
}
73+
7074
return &conf, nil
7175
}
7276

bib/internal/buildconfig/config_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,16 @@ func TestReadLegacyJSONConfig(t *testing.T) {
134134
assert.Equal(t, expectedBuildConfig, cfg)
135135
}
136136

137+
func TestTomlUnknownKeysError(t *testing.T) {
138+
fakeUserCnfPath := makeFakeConfig(t, "config.toml", `
139+
[[birds]]
140+
name = "toucan"
141+
`)
142+
_, err := buildconfig.ReadWithFallback(fakeUserCnfPath)
143+
144+
assert.ErrorContains(t, err, "unknown keys found: [birds birds.name]")
145+
}
146+
137147
func TestJsonUnknownKeysError(t *testing.T) {
138148
fakeUserCnfPath := makeFakeConfig(t, "config.json", `
139149
{

0 commit comments

Comments
 (0)