daemon: remove redundant capturing of loop vars (copyloopvar)

daemon/daemon_unix_test.go:277:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    daemon/delete_test.go:71:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    daemon/exec_linux_test.go:65:4: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
                tc := tc
                ^
    daemon/info_unix_test.go:54:3: The copy of the 'for' variable "test" can be deleted (Go 1.22+) (copyloopvar)
            test := test
            ^
    daemon/runtime_unix_test.go:173:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    daemon/runtime_unix_test.go:333:3: The copy of the 'for' variable "tt" can be deleted (Go 1.22+) (copyloopvar)
            tt := tt
            ^
    daemon/seccomp_linux_test.go:194:3: The copy of the 'for' variable "x" can be deleted (Go 1.22+) (copyloopvar)
            x := x
            ^
    daemon/top_unix_test.go:88: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-12 13:37:59 +01:00
parent d885d097ef
commit b5c0f6cd70
7 changed files with 26 additions and 34 deletions

View File

@@ -50,17 +50,16 @@ func TestParseInitVersion(t *testing.T) {
},
}
for _, test := range tests {
test := test
t.Run(test.output, func(t *testing.T) {
version, commit, err := parseInitVersion(test.output)
if test.invalid {
for _, tc := range tests {
t.Run(tc.output, func(t *testing.T) {
version, commit, err := parseInitVersion(tc.output)
if tc.invalid {
assert.Check(t, is.ErrorContains(err, ""))
} else {
assert.Check(t, err)
}
assert.Equal(t, test.version, version)
assert.Equal(t, test.commit, commit)
assert.Equal(t, tc.version, version)
assert.Equal(t, tc.commit, commit)
})
}
}
@@ -117,15 +116,15 @@ spec: 1.0.0
},
}
for _, test := range tests {
runtime, version, commit, err := parseRuntimeVersion(test.output)
if test.invalid {
for _, tc := range tests {
runtime, version, commit, err := parseRuntimeVersion(tc.output)
if tc.invalid {
assert.Check(t, is.ErrorContains(err, ""))
} else {
assert.Check(t, err)
}
assert.Equal(t, test.runtime, runtime)
assert.Equal(t, test.version, version)
assert.Equal(t, test.commit, commit)
assert.Equal(t, tc.runtime, runtime)
assert.Equal(t, tc.version, version)
assert.Equal(t, tc.commit, commit)
}
}