Skip to content

Commit

Permalink
add sane timeuot to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mfridman committed Oct 9, 2023
1 parent d924454 commit e1c1cf8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lock/postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ func TestPostgresSessionLocker(t *testing.T) {
t.Run("lock_and_unlock", func(t *testing.T) {
locker, err := lock.NewPostgresSessionLocker(
lock.WithLockID(lockID),
lock.WithLockTimeout(4*time.Second),
lock.WithUnlockTimeout(4*time.Second),
)
check.NoError(t, err)
ctx := context.Background()
Expand Down Expand Up @@ -56,7 +58,10 @@ func TestPostgresSessionLocker(t *testing.T) {
check.Number(t, len(pgLocks), 0)
})
t.Run("lock_close_conn_unlock", func(t *testing.T) {
locker, err := lock.NewPostgresSessionLocker()
locker, err := lock.NewPostgresSessionLocker(
lock.WithLockTimeout(4*time.Second),
lock.WithUnlockTimeout(4*time.Second),
)
check.NoError(t, err)
ctx := context.Background()
conn, err := db.Conn(ctx)
Expand Down Expand Up @@ -97,7 +102,8 @@ func TestPostgresSessionLocker(t *testing.T) {
// Exactly one connection should acquire the lock. While the other connections
// should fail to acquire the lock and timeout.
locker, err := lock.NewPostgresSessionLocker(
lock.WithLockTimeout(4 * time.Second),
lock.WithLockTimeout(4*time.Second),
lock.WithUnlockTimeout(4*time.Second),
)
check.NoError(t, err)
ch <- locker.SessionLock(ctx, conn)
Expand Down Expand Up @@ -131,6 +137,7 @@ func TestPostgresSessionLocker(t *testing.T) {
)
locker, err := lock.NewPostgresSessionLocker(
lock.WithLockID(lockID),
lock.WithLockTimeout(4*time.Second),
lock.WithUnlockTimeout(4*time.Second),
)
check.NoError(t, err)
Expand Down

0 comments on commit e1c1cf8

Please sign in to comment.