@@ -44,13 +44,14 @@ func TestMounts(t *testing.T) {
4444 "bind" ,
4545 }
4646
47- logger , logHook := testlog .NewNullLogger ()
47+ logger , _ := testlog .NewNullLogger ()
4848
4949 testCases := []struct {
5050 description string
5151 expectedError error
5252 expectedMounts []Mount
5353 input * mounts
54+ repeat int
5455 }{
5556 {
5657 description : "nill lookup returns error" ,
@@ -159,31 +160,68 @@ func TestMounts(t *testing.T) {
159160 {Path : "/located" , HostPath : "/some/root/located" , Options : mountOptions },
160161 },
161162 },
163+ {
164+ description : "multiple mounts ordering" ,
165+ input : & mounts {
166+ lookup : & lookup.LocatorMock {
167+ LocateFunc : func (s string ) ([]string , error ) {
168+ return []string {
169+ "first" ,
170+ "second" ,
171+ "third" ,
172+ "fourth" ,
173+ "second" ,
174+ "second" ,
175+ "second" ,
176+ "fifth" ,
177+ "sixth" }, nil
178+ },
179+ },
180+ required : []string {"" },
181+ },
182+ expectedMounts : []Mount {
183+ {Path : "first" , HostPath : "first" , Options : mountOptions },
184+ {Path : "second" , HostPath : "second" , Options : mountOptions },
185+ {Path : "third" , HostPath : "third" , Options : mountOptions },
186+ {Path : "fourth" , HostPath : "fourth" , Options : mountOptions },
187+ {Path : "fifth" , HostPath : "fifth" , Options : mountOptions },
188+ {Path : "sixth" , HostPath : "sixth" , Options : mountOptions },
189+ },
190+ repeat : 10 ,
191+ },
162192 }
163193
164194 for _ , tc := range testCases {
165- logHook .Reset ()
166- t .Run (tc .description , func (t * testing.T ) {
167- tc .input .logger = logger
168- mounts , err := tc .input .Mounts ()
169-
170- if tc .expectedError != nil {
171- require .Error (t , err )
172- } else {
173- require .NoError (t , err )
195+ for i := 1 ; ; i ++ {
196+ test_name := tc .description
197+ if tc .repeat > 1 {
198+ test_name += fmt .Sprintf ("/%d" , i )
174199 }
175- require .ElementsMatch (t , tc .expectedMounts , mounts )
200+ success := t .Run (test_name , func (t * testing.T ) {
201+ tc .input .logger = logger
202+ mounts , err := tc .input .Mounts ()
203+
204+ if tc .expectedError != nil {
205+ require .Error (t , err )
206+ } else {
207+ require .NoError (t , err )
208+ }
209+ require .EqualValues (t , tc .expectedMounts , mounts )
176210
177- // We check that the mock is called for each element of required
178- if tc .input .lookup != nil {
179- mock := tc .input .lookup .(* lookup.LocatorMock )
180- require .Len (t , mock .LocateCalls (), len (tc .input .required ))
181- var args []string
182- for _ , c := range mock .LocateCalls () {
183- args = append (args , c .S )
211+ // We check that the mock is called for each element of required
212+ if i == 1 && tc .input .lookup != nil {
213+ mock := tc .input .lookup .(* lookup.LocatorMock )
214+ require .Len (t , mock .LocateCalls (), len (tc .input .required ))
215+ var args []string
216+ for _ , c := range mock .LocateCalls () {
217+ args = append (args , c .S )
218+ }
219+ require .EqualValues (t , args , tc .input .required )
184220 }
185- require .EqualValues (t , args , tc .input .required )
221+ })
222+ if ! success || i >= tc .repeat {
223+ break
186224 }
187- })
225+ }
188226 }
189227}
0 commit comments