@@ -168,27 +168,41 @@ func TestBrokenCredentialsStore(t *testing.T) {
168
168
},
169
169
}
170
170
171
- t .Run ("Broken Docker Config testing" , func (t * testing.T ) {
171
+ t .Run ("Docker Config testing with a variety of filesystem situations" , func (t * testing.T ) {
172
+ // Do NOT parallelize this test, as it relies on Chdir, which would have side effects for other tests.
172
173
registryURL , err := Parse ("registry" )
173
174
if err != nil {
174
175
t .Fatal (err )
175
176
}
176
177
177
- for _ , tc := range testCases {
178
- t .Run (tc .description , func (t * testing.T ) {
178
+ for _ , testCase := range testCases {
179
+ tc := testCase
180
+ t .Run (tc .description , func (tt * testing.T ) {
181
+ // See https://github.com/containerd/nerdctl/issues/3413
182
+ var oldpwd string
179
183
directory := tc .setup ()
180
- cs , err := NewCredentialsStore (directory )
181
- assert .ErrorIs (t , err , tc .errorNew )
184
+ oldpwd , err = os .Getwd ()
185
+ assert .NilError (tt , err )
186
+ // Ignore the error, as the destination may not be a directory
187
+ _ = os .Chdir (directory )
188
+ tt .Cleanup (func () {
189
+ err = os .Chdir (oldpwd )
190
+ assert .NilError (tt , err )
191
+ })
192
+
193
+ var cs * CredentialsStore
194
+ cs , err = NewCredentialsStore (directory )
195
+ assert .ErrorIs (tt , err , tc .errorNew )
182
196
if err != nil {
183
197
return
184
198
}
185
199
186
200
var af * Credentials
187
201
af , err = cs .Retrieve (registryURL , true )
188
- assert .ErrorIs (t , err , tc .errorRead )
202
+ assert .ErrorIs (tt , err , tc .errorRead )
189
203
190
204
err = cs .Store (registryURL , af )
191
- assert .ErrorIs (t , err , tc .errorWrite )
205
+ assert .ErrorIs (tt , err , tc .errorWrite )
192
206
})
193
207
}
194
208
})
0 commit comments