mirror of https://github.com/docker/cli.git
templates: 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
046ac9714c
commit
7d9ea25564
|
@ -64,25 +64,23 @@ func TestParseTruncateFunction(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
testCase := testCase
|
||||
|
||||
tm, err := Parse(testCase.template)
|
||||
for _, tc := range testCases {
|
||||
tm, err := Parse(tc.template)
|
||||
assert.NilError(t, err)
|
||||
|
||||
t.Run("Non Empty Source Test with template: "+testCase.template, func(t *testing.T) {
|
||||
t.Run("Non Empty Source Test with template: "+tc.template, func(t *testing.T) {
|
||||
var b bytes.Buffer
|
||||
assert.NilError(t, tm.Execute(&b, source))
|
||||
assert.Check(t, is.Equal(testCase.expected, b.String()))
|
||||
assert.Check(t, is.Equal(tc.expected, b.String()))
|
||||
})
|
||||
|
||||
t.Run("Empty Source Test with template: "+testCase.template, func(t *testing.T) {
|
||||
t.Run("Empty Source Test with template: "+tc.template, func(t *testing.T) {
|
||||
var c bytes.Buffer
|
||||
assert.NilError(t, tm.Execute(&c, ""))
|
||||
assert.Check(t, is.Equal("", c.String()))
|
||||
})
|
||||
|
||||
t.Run("Nil Source Test with template: "+testCase.template, func(t *testing.T) {
|
||||
t.Run("Nil Source Test with template: "+tc.template, func(t *testing.T) {
|
||||
var c bytes.Buffer
|
||||
assert.Check(t, tm.Execute(&c, nil) != nil)
|
||||
assert.Check(t, is.Equal("", c.String()))
|
||||
|
|
Loading…
Reference in New Issue