@@ -45,13 +45,14 @@ func TestMounts(t *testing.T) {
4545 "rprivate" ,
4646 }
4747
48- logger , logHook := testlog .NewNullLogger ()
48+ logger , _ := testlog .NewNullLogger ()
4949
5050 testCases := []struct {
5151 description string
5252 expectedError error
5353 expectedMounts []Mount
5454 input * mounts
55+ repeat int
5556 }{
5657 {
5758 description : "nill lookup returns error" ,
@@ -160,31 +161,68 @@ func TestMounts(t *testing.T) {
160161 {Path : "/located" , HostPath : "/some/root/located" , Options : mountOptions },
161162 },
162163 },
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+ },
163193 }
164194
165195 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 )
175200 }
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 )
177211
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 )
185221 }
186- require .EqualValues (t , args , tc .input .required )
222+ })
223+ if ! success || i >= tc .repeat {
224+ break
187225 }
188- })
226+ }
189227 }
190228}
0 commit comments