From c18dd2719eea90959b470b61d6e7806bacb323de Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 16 Nov 2022 19:46:08 +0100 Subject: [PATCH] cli/compose/loader: TestMarshallConfig: fix duplicate version The version was originally added in 570ee9cb5406e2ec0513e578bc71c730f5e616b6, at the time the `expected` config did not have a `version:` field. A later refactor in 0cf2e6353a88a12b78da72db6a7e7c7d049d3ed8 updated the `expected` config to have a `version:` included. However, the test was not updated, which now resulted in the test using a compose file with a duplicate version field: version: '3.10' version: "3.10" services: foo: build: This issue was masked by `yaml.Unmarshal()` from `gopkg.in/yaml.v2` which silently ignores the duplicate, taking the value of the last occurrence. When upgrading to `gopkg.in/yaml.v3`, the duplicate value resulted in an error: yaml: unmarshal errors: line 2: mapping key "version" already defined at line 1 Signed-off-by: Sebastiaan van Stijn --- cli/compose/loader/types_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/compose/loader/types_test.go b/cli/compose/loader/types_test.go index 55e37e97e7..0823509c8e 100644 --- a/cli/compose/loader/types_test.go +++ b/cli/compose/loader/types_test.go @@ -19,8 +19,8 @@ func TestMarshallConfig(t *testing.T) { assert.NilError(t, err) assert.Check(t, is.Equal(expected, string(actual))) - // Make sure the expected still - dict, err := ParseYAML([]byte("version: '3.10'\n" + expected)) + // Make sure the expected can be parsed. + dict, err := ParseYAML([]byte(expected)) assert.NilError(t, err) _, err = Load(buildConfigDetails(dict, map[string]string{})) assert.NilError(t, err)