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

Function TestMultiLocker_Lock_Success

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

Source from the content-addressed store, hash-verified

178}
179
180func 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
195func TestMultiLocker_Lock_RollbackOnPartialFailure(t *testing.T) {
196 db, mock := redismock.NewClientMock()

Callers

nothing calls this directly

Calls 2

LockMethod · 0.95
NewMultiLockerFunction · 0.85

Tested by

no test coverage detected