cli/compose: remove redundant capturing of loop vars in tests (copyloopvar)

go1.22 and up now produce a unique variable in loops, tehrefore no longer
requiring to capture the variable manually;

    service/logs/parse_logs_test.go:50:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2024-11-05 09:58:38 +01:00
parent 67458f710d
commit 1448cecba1
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
4 changed files with 4 additions and 9 deletions

View File

@ -409,7 +409,6 @@ func TestConvertCredentialSpec(t *testing.T) {
} }
for _, tc := range tests { for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
namespace := NewNamespace(tc.name) namespace := NewNamespace(tc.name)
swarmSpec, err := convertCredentialSpec(namespace, tc.in, tc.configs) swarmSpec, err := convertCredentialSpec(namespace, tc.in, tc.configs)
@ -691,7 +690,6 @@ func TestConvertServiceCapAddAndCapDrop(t *testing.T) {
}, },
} }
for _, tc := range tests { for _, tc := range tests {
tc := tc
t.Run(tc.title, func(t *testing.T) { t.Run(tc.title, func(t *testing.T) {
result, err := Service("1.41", Namespace{name: "foo"}, tc.in, nil, nil, nil, nil) result, err := Service("1.41", Namespace{name: "foo"}, tc.in, nil, nil, nil, nil)
assert.NilError(t, err) assert.NilError(t, err)

View File

@ -1626,13 +1626,12 @@ services:
init: &booleanFalse, init: &booleanFalse,
}, },
} }
for _, testcase := range testcases { for _, tc := range testcases {
testcase := testcase t.Run(tc.doc, func(t *testing.T) {
t.Run(testcase.doc, func(t *testing.T) { config, err := loadYAML(tc.yaml)
config, err := loadYAML(testcase.yaml)
assert.NilError(t, err) assert.NilError(t, err)
assert.Check(t, is.Len(config.Services, 1)) assert.Check(t, is.Len(config.Services, 1))
assert.Check(t, is.DeepEqual(testcase.init, config.Services[0].Init)) assert.Check(t, is.DeepEqual(tc.init, config.Services[0].Init))
}) })
} }
} }

View File

@ -215,7 +215,6 @@ func TestValidateCredentialSpecs(t *testing.T) {
} }
for _, tc := range tests { for _, tc := range tests {
tc := tc
t.Run(tc.version, func(t *testing.T) { t.Run(tc.version, func(t *testing.T) {
config := dict{ config := dict{
"version": "99.99", "version": "99.99",

View File

@ -277,7 +277,6 @@ func TestExtractVariables(t *testing.T) {
}, },
} }
for _, tc := range testCases { for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
actual := ExtractVariables(tc.dict, defaultPattern) actual := ExtractVariables(tc.dict, defaultPattern)
assert.Check(t, is.DeepEqual(actual, tc.expected)) assert.Check(t, is.DeepEqual(actual, tc.expected))