(t *testing.T)
| 100 | } |
| 101 | |
| 102 | func TestLocker_WaitLock_Success(t *testing.T) { |
| 103 | db, mock := redismock.NewClientMock() |
| 104 | locker := NewLocker(db, "test-key", "test-value") |
| 105 | |
| 106 | mock.ExpectSetNX("test-key", "test-value", 5*time.Second).SetVal(true) |
| 107 | |
| 108 | err := locker.WaitLock(context.Background(), 5*time.Second, 2*time.Second) |
| 109 | assert.NoError(t, err) |
| 110 | assert.NoError(t, mock.ExpectationsWereMet()) |
| 111 | } |
| 112 | |
| 113 | func TestLocker_WaitLock_ContextCanceled(t *testing.T) { |
| 114 | db, mock := redismock.NewClientMock() |