(t *testing.T)
| 37 | } |
| 38 | |
| 39 | func TestLocker_Lock_Failure(t *testing.T) { |
| 40 | db, mock := redismock.NewClientMock() |
| 41 | locker := NewLocker(db, "test-key", "test-value") |
| 42 | |
| 43 | mock.ExpectSetNX("test-key", "test-value", 5*time.Second).SetVal(false) |
| 44 | |
| 45 | err := locker.Lock(context.Background(), 5*time.Second) |
| 46 | assert.EqualError(t, err, "lock for key test-key is already held") |
| 47 | assert.NoError(t, mock.ExpectationsWereMet()) |
| 48 | } |
| 49 | |
| 50 | func TestLocker_Unlock_Success(t *testing.T) { |
| 51 | db, mock := redismock.NewClientMock() |