Skip to content

Commit 96ebdfa

Browse files
author
Keerthan Mala
committed
add unit tests
1 parent 5cf4df4 commit 96ebdfa

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

pkg/sshd/lock_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package sshd
22

33
import (
4+
"errors"
45
"sync"
56
"testing"
67
"time"
@@ -12,6 +13,10 @@ const (
1213
callbackTimeout = 1 * time.Second
1314
)
1415

16+
var (
17+
gitError = errors.New("git receive error")
18+
)
19+
1520
func TestMultipleSameRepoLocks(t *testing.T) {
1621
var wg sync.WaitGroup
1722
const repo = "repo1"
@@ -91,7 +96,10 @@ func TestWrapInLock(t *testing.T) {
9196
assert.NoErr(t, wrapInLock(lck, "repo", func() error {
9297
return nil
9398
}))
94-
lck.Lock("repo")
99+
assert.Err(t, gitError, wrapInLock(lck, "repo", func() error {
100+
return gitError
101+
}))
102+
assert.NoErr(t, lck.Lock("repo"))
95103
assert.Err(t, errAlreadyLocked, wrapInLock(lck, "repo", func() error {
96104
return nil
97105
}))

0 commit comments

Comments
 (0)