(t *testing.T)
| 178 | } |
| 179 | |
| 180 | func TestMultiLocker_Lock_Success(t *testing.T) { |
| 181 | db, mock := redismock.NewClientMock() |
| 182 | |
| 183 | // Keys will be sorted to: key-a, key-b |
| 184 | multiLocker := NewMultiLocker(db, []string{"key-b", "key-a"}, "test-value") |
| 185 | |
| 186 | // Expect locks to be acquired in sorted order |
| 187 | mock.ExpectSetNX("key-a", "test-value", 5*time.Second).SetVal(true) |
| 188 | mock.ExpectSetNX("key-b", "test-value", 5*time.Second).SetVal(true) |
| 189 | |
| 190 | err := multiLocker.Lock(context.Background(), 5*time.Second) |
| 191 | assert.NoError(t, err) |
| 192 | assert.NoError(t, mock.ExpectationsWereMet()) |
| 193 | } |
| 194 | |
| 195 | func TestMultiLocker_Lock_RollbackOnPartialFailure(t *testing.T) { |
| 196 | db, mock := redismock.NewClientMock() |
nothing calls this directly
no test coverage detected