MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / TestMultiLocker_Unlock_Success

Function TestMultiLocker_Unlock_Success

internal/lock/lock_test.go:217–231  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

215}
216
217func 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
233func TestMultiLocker_Unlock_ReturnsLastError(t *testing.T) {
234 db, mock := redismock.NewClientMock()

Callers

nothing calls this directly

Calls 2

UnlockMethod · 0.95
NewMultiLockerFunction · 0.85

Tested by

no test coverage detected