(t *testing.T)
| 215 | } |
| 216 | |
| 217 | func TestMultiLocker_Unlock_Success(t *testing.T) { |
| 218 | db, mock := redismock.NewClientMock() |
| 219 | |
| 220 | // Keys will be sorted to: key-a, key-b |
| 221 | multiLocker := NewMultiLocker(db, []string{"key-b", "key-a"}, "test-value") |
| 222 | |
| 223 | // Unlock should release locks in reverse order (key-b, key-a) |
| 224 | unlockScript := "if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('del', KEYS[1]) else return 0 end" |
| 225 | mock.ExpectEval(unlockScript, []string{"key-b"}, "test-value").SetVal(int64(1)) |
| 226 | mock.ExpectEval(unlockScript, []string{"key-a"}, "test-value").SetVal(int64(1)) |
| 227 | |
| 228 | err := multiLocker.Unlock(context.Background()) |
| 229 | assert.NoError(t, err) |
| 230 | assert.NoError(t, mock.ExpectationsWereMet()) |
| 231 | } |
| 232 | |
| 233 | func TestMultiLocker_Unlock_ReturnsLastError(t *testing.T) { |
| 234 | db, mock := redismock.NewClientMock() |
nothing calls this directly
no test coverage detected