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

Function TestMultiLocker_WaitLock_Success

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

Source from the content-addressed store, hash-verified

247}
248
249func TestMultiLocker_WaitLock_Success(t *testing.T) {
250 db, mock := redismock.NewClientMock()
251
252 multiLocker := NewMultiLocker(db, []string{"key-b", "key-a"}, "test-value")
253
254 // Expect locks to be acquired in sorted order
255 mock.ExpectSetNX("key-a", "test-value", 5*time.Second).SetVal(true)
256 mock.ExpectSetNX("key-b", "test-value", 5*time.Second).SetVal(true)
257
258 err := multiLocker.WaitLock(context.Background(), 5*time.Second, 2*time.Second)
259 assert.NoError(t, err)
260 assert.NoError(t, mock.ExpectationsWereMet())
261}
262
263func TestMultiLocker_WaitLock_ContextCanceled(t *testing.T) {
264 db, mock := redismock.NewClientMock()

Callers

nothing calls this directly

Calls 2

WaitLockMethod · 0.95
NewMultiLockerFunction · 0.85

Tested by

no test coverage detected