@@ -15,59 +15,59 @@ const (
1515func TestMultipleSameRepoLocks (t * testing.T ) {
1616 var wg sync.WaitGroup
1717 const repo = "repo1"
18- const numTries = 100
19- lck := NewInMemoryRepositoryLock ()
20- assert .NoErr (t , lck .Lock (repo , 0 * time . Second ))
18+ const numTries = 0
19+ lck := NewInMemoryRepositoryLock (0 )
20+ assert .NoErr (t , lck .Lock (repo ))
2121 for i := 0 ; i < numTries ; i ++ {
2222 wg .Add (1 )
2323 go func () {
2424 defer wg .Done ()
25- assert .True (t , lck .Lock (repo , 0 * time . Second ) != nil , "lock of already locked repo should return error" )
25+ assert .True (t , lck .Lock (repo ) != nil , "lock of already locked repo should return error" )
2626 }()
2727 }
2828 assert .NoErr (t , waitWithTimeout (& wg , 1 * time .Second ))
29- assert .NoErr (t , lck .Unlock (repo , 0 * time . Second ))
29+ assert .NoErr (t , lck .Unlock (repo ))
3030 for i := 0 ; i < numTries ; i ++ {
3131 wg .Add (1 )
3232 go func () {
3333 defer wg .Done ()
34- assert .True (t , lck .Unlock (repo , 0 * time . Second ) != nil , "unlock of already unlocked repo should return error" )
34+ assert .True (t , lck .Unlock (repo ) != nil , "unlock of already unlocked repo should return error" )
3535 }()
3636 }
3737 assert .NoErr (t , waitWithTimeout (& wg , 1 * time .Second ))
3838}
3939
4040func TestSingleLock (t * testing.T ) {
41- rl := NewInMemoryRepositoryLock ()
41+ rl := NewInMemoryRepositoryLock (0 )
4242 key := "fakeid"
4343 callbackCh := make (chan interface {})
4444 go lockAndCallback (rl , key , callbackCh )
4545 verifyCallbackHappens (t , callbackCh )
4646}
4747
4848func TestSingleLockUnlock (t * testing.T ) {
49- rl := NewInMemoryRepositoryLock ()
49+ rl := NewInMemoryRepositoryLock (0 )
5050 key := "fakeid"
5151 callbackCh := make (chan interface {})
5252 go lockAndCallback (rl , key , callbackCh )
5353 verifyCallbackHappens (t , callbackCh )
54- err := rl .Unlock (key , time . Duration ( 0 ) )
54+ err := rl .Unlock (key )
5555 if err != nil {
5656 t .Fatalf ("unexpected error %v" , err )
5757 }
5858}
5959
6060func TestInvalidUnlock (t * testing.T ) {
61- rl := NewInMemoryRepositoryLock ()
61+ rl := NewInMemoryRepositoryLock (0 )
6262 key := "fakeid"
63- err := rl .Unlock (key , time . Duration ( 0 ) )
63+ err := rl .Unlock (key )
6464 if err == nil {
6565 t .Fatal ("expected error but returned nil" )
6666 }
6767}
6868
6969func TestDoubleLockUnlock (t * testing.T ) {
70- rl := NewInMemoryRepositoryLock ()
70+ rl := NewInMemoryRepositoryLock (0 )
7171 key := "fakeid"
7272 callbackCh1stLock := make (chan interface {})
7373 callbackCh2ndLock := make (chan interface {})
@@ -76,29 +76,29 @@ func TestDoubleLockUnlock(t *testing.T) {
7676 verifyCallbackHappens (t , callbackCh1stLock )
7777 go lockAndCallback (rl , key , callbackCh2ndLock )
7878 verifyCallbackDoesntHappens (t , callbackCh2ndLock )
79- err := rl .Unlock (key , time . Duration ( 0 ) )
79+ err := rl .Unlock (key )
8080 if err != nil {
8181 t .Fatalf ("unexpected error %v" , err )
8282 }
83- err = rl .Unlock (key , time . Duration ( 0 ) )
83+ err = rl .Unlock (key )
8484 if err == nil {
8585 t .Fatalf ("expected error but returned nil" )
8686 }
8787}
8888
8989func TestWrapInLock (t * testing.T ) {
90- lck := NewInMemoryRepositoryLock ()
91- assert .NoErr (t , wrapInLock (lck , "repo" , 0 * time . Second , func () error {
90+ lck := NewInMemoryRepositoryLock (0 )
91+ assert .NoErr (t , wrapInLock (lck , "repo" , func () error {
9292 return nil
9393 }))
94- lck .Lock ("repo" , 0 * time . Second )
95- assert .Err (t , errAlreadyLocked , wrapInLock (lck , "repo" , 0 * time . Second , func () error {
94+ lck .Lock ("repo" )
95+ assert .Err (t , errAlreadyLocked , wrapInLock (lck , "repo" , func () error {
9696 return nil
9797 }))
9898}
9999
100100func lockAndCallback (rl RepositoryLock , id string , callbackCh chan <- interface {}) {
101- if err := rl .Lock (id , time . Duration ( 0 ) ); err == nil {
101+ if err := rl .Lock (id ); err == nil {
102102 callbackCh <- true
103103 }
104104}
0 commit comments