oci: fix loop iterator aliasing

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
Akihiro Suda 2023-01-14 13:45:45 +09:00
parent 676b942fef
commit ef2560d166
No known key found for this signature in database
GPG Key ID: 49524C6F9F638F1A

View File

@ -70,6 +70,7 @@ guest:x:405:100:guest:/dev/null:/sbin/nologin
}, },
} }
for _, testCase := range testCases { for _, testCase := range testCases {
testCase := testCase
t.Run(fmt.Sprintf("user %d", testCase.userID), func(t *testing.T) { t.Run(fmt.Sprintf("user %d", testCase.userID), func(t *testing.T) {
t.Parallel() t.Parallel()
s := Spec{ s := Spec{
@ -129,6 +130,7 @@ guest:x:405:100:guest:/dev/null:/sbin/nologin
}, },
} }
for _, testCase := range testCases { for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.user, func(t *testing.T) { t.Run(testCase.user, func(t *testing.T) {
t.Parallel() t.Parallel()
s := Spec{ s := Spec{
@ -178,11 +180,11 @@ sys:x:3:root,bin,adm
}{ }{
{ {
user: "root", user: "root",
expected: []uint32{}, expected: []uint32{1, 2, 3},
}, },
{ {
user: "1000", user: "1000",
expected: []uint32{}, expected: nil,
}, },
{ {
user: "bin", user: "bin",
@ -198,6 +200,7 @@ sys:x:3:root,bin,adm
}, },
} }
for _, testCase := range testCases { for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.user, func(t *testing.T) { t.Run(testCase.user, func(t *testing.T) {
t.Parallel() t.Parallel()
s := Spec{ s := Spec{
@ -490,6 +493,7 @@ daemon:x:2:root,bin,daemon
} }
for _, testCase := range testCases { for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.name, func(t *testing.T) { t.Run(testCase.name, func(t *testing.T) {
t.Parallel() t.Parallel()
s := Spec{ s := Spec{