@@ -45,13 +45,14 @@ func TestMounts(t *testing.T) {
45
45
"rprivate" ,
46
46
}
47
47
48
- logger , logHook := testlog .NewNullLogger ()
48
+ logger , _ := testlog .NewNullLogger ()
49
49
50
50
testCases := []struct {
51
51
description string
52
52
expectedError error
53
53
expectedMounts []Mount
54
54
input * mounts
55
+ repeat int
55
56
}{
56
57
{
57
58
description : "nill lookup returns error" ,
@@ -160,31 +161,68 @@ func TestMounts(t *testing.T) {
160
161
{Path : "/located" , HostPath : "/some/root/located" , Options : mountOptions },
161
162
},
162
163
},
164
+ {
165
+ description : "multiple mounts ordering" ,
166
+ input : & mounts {
167
+ lookup : & lookup.LocatorMock {
168
+ LocateFunc : func (s string ) ([]string , error ) {
169
+ return []string {
170
+ "first" ,
171
+ "second" ,
172
+ "third" ,
173
+ "fourth" ,
174
+ "second" ,
175
+ "second" ,
176
+ "second" ,
177
+ "fifth" ,
178
+ "sixth" }, nil
179
+ },
180
+ },
181
+ required : []string {"" },
182
+ },
183
+ expectedMounts : []Mount {
184
+ {Path : "first" , HostPath : "first" , Options : mountOptions },
185
+ {Path : "second" , HostPath : "second" , Options : mountOptions },
186
+ {Path : "third" , HostPath : "third" , Options : mountOptions },
187
+ {Path : "fourth" , HostPath : "fourth" , Options : mountOptions },
188
+ {Path : "fifth" , HostPath : "fifth" , Options : mountOptions },
189
+ {Path : "sixth" , HostPath : "sixth" , Options : mountOptions },
190
+ },
191
+ repeat : 10 ,
192
+ },
163
193
}
164
194
165
195
for _ , tc := range testCases {
166
- logHook .Reset ()
167
- t .Run (tc .description , func (t * testing.T ) {
168
- tc .input .logger = logger
169
- mounts , err := tc .input .Mounts ()
170
-
171
- if tc .expectedError != nil {
172
- require .Error (t , err )
173
- } else {
174
- require .NoError (t , err )
196
+ for i := 1 ; ; i ++ {
197
+ test_name := tc .description
198
+ if tc .repeat > 1 {
199
+ test_name += fmt .Sprintf ("/%d" , i )
175
200
}
176
- require .ElementsMatch (t , tc .expectedMounts , mounts )
201
+ success := t .Run (test_name , func (t * testing.T ) {
202
+ tc .input .logger = logger
203
+ mounts , err := tc .input .Mounts ()
204
+
205
+ if tc .expectedError != nil {
206
+ require .Error (t , err )
207
+ } else {
208
+ require .NoError (t , err )
209
+ }
210
+ require .EqualValues (t , tc .expectedMounts , mounts )
177
211
178
- // We check that the mock is called for each element of required
179
- if tc .input .lookup != nil {
180
- mock := tc .input .lookup .(* lookup.LocatorMock )
181
- require .Len (t , mock .LocateCalls (), len (tc .input .required ))
182
- var args []string
183
- for _ , c := range mock .LocateCalls () {
184
- args = append (args , c .S )
212
+ // We check that the mock is called for each element of required
213
+ if i == 1 && tc .input .lookup != nil {
214
+ mock := tc .input .lookup .(* lookup.LocatorMock )
215
+ require .Len (t , mock .LocateCalls (), len (tc .input .required ))
216
+ var args []string
217
+ for _ , c := range mock .LocateCalls () {
218
+ args = append (args , c .S )
219
+ }
220
+ require .EqualValues (t , args , tc .input .required )
185
221
}
186
- require .EqualValues (t , args , tc .input .required )
222
+ })
223
+ if ! success || i >= tc .repeat {
224
+ break
187
225
}
188
- })
226
+ }
189
227
}
190
228
}
0 commit comments