mirror of https://github.com/docker/cli.git
opts: 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:
parent
417974cdc3
commit
762b5a8df3
|
@ -36,7 +36,6 @@ func TestNormalizeCapability(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
tc := tc
|
||||
t.Run(tc.in, func(t *testing.T) {
|
||||
assert.Equal(t, NormalizeCapability(tc.in), tc.out)
|
||||
})
|
||||
|
@ -108,7 +107,6 @@ func TestEffectiveCapAddCapDrop(t *testing.T) {
|
|||
}
|
||||
|
||||
for i, tc := range tests {
|
||||
tc := tc
|
||||
t.Run(strconv.Itoa(i), func(t *testing.T) {
|
||||
add, drop := EffectiveCapAddCapDrop(tc.in.add, tc.in.drop)
|
||||
assert.DeepEqual(t, add, tc.out.add)
|
||||
|
|
|
@ -64,7 +64,6 @@ func TestConfigOptions(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
var opt ConfigOpt
|
||||
assert.NilError(t, opt.Set(tc.input))
|
||||
|
|
|
@ -104,7 +104,6 @@ func TestValidateEnv(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
tc := tc
|
||||
t.Run(tc.value, func(t *testing.T) {
|
||||
actual, err := ValidateEnv(tc.value)
|
||||
|
||||
|
|
|
@ -281,7 +281,6 @@ func TestValidateExtraHosts(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
tc := tc
|
||||
if tc.expectedOut == "" {
|
||||
tc.expectedOut = tc.input
|
||||
}
|
||||
|
|
|
@ -114,7 +114,6 @@ func TestNetworkOptAdvancedSyntax(t *testing.T) {
|
|||
},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.value, func(t *testing.T) {
|
||||
var network NetworkOpt
|
||||
assert.NilError(t, network.Set(tc.value))
|
||||
|
@ -142,7 +141,6 @@ func TestNetworkOptAdvancedSyntaxInvalid(t *testing.T) {
|
|||
},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.value, func(t *testing.T) {
|
||||
var network NetworkOpt
|
||||
assert.ErrorContains(t, network.Set(tc.value), tc.expectedError)
|
||||
|
|
|
@ -69,7 +69,6 @@ func TestValidateIPAddress(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
tc := tc
|
||||
t.Run(tc.input, func(t *testing.T) {
|
||||
actualOut, actualErr := ValidateIPAddress(tc.input)
|
||||
assert.Check(t, is.Equal(tc.expectedOut, actualOut))
|
||||
|
@ -339,7 +338,6 @@ func TestValidateLabel(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
val, err := ValidateLabel(tc.value)
|
||||
if tc.expectedErr != "" {
|
||||
|
|
|
@ -61,7 +61,6 @@ NO_SUCH_ENV
|
|||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
envs, err := ReadKVEnvStrings(tc.files, tc.overrides)
|
||||
assert.NilError(t, err)
|
||||
|
|
|
@ -344,7 +344,6 @@ func TestConvertPortToPortConfigWithIP(t *testing.T) {
|
|||
var b bytes.Buffer
|
||||
logrus.SetOutput(&b)
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.value, func(t *testing.T) {
|
||||
_, err := ConvertPortToPortConfig("80/tcp", map[nat.Port][]nat.PortBinding{
|
||||
"80/tcp": {{HostIP: tc.value, HostPort: "2345"}},
|
||||
|
|
|
@ -64,7 +64,6 @@ func TestSecretOptions(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
var opt SecretOpt
|
||||
assert.NilError(t, opt.Set(tc.input))
|
||||
|
|
Loading…
Reference in New Issue