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

Function TestLocker_Lock_Failure

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

Source from the content-addressed store, hash-verified

37}
38
39func TestLocker_Lock_Failure(t *testing.T) {
40 db, mock := redismock.NewClientMock()
41 locker := NewLocker(db, "test-key", "test-value")
42
43 mock.ExpectSetNX("test-key", "test-value", 5*time.Second).SetVal(false)
44
45 err := locker.Lock(context.Background(), 5*time.Second)
46 assert.EqualError(t, err, "lock for key test-key is already held")
47 assert.NoError(t, mock.ExpectationsWereMet())
48}
49
50func TestLocker_Unlock_Success(t *testing.T) {
51 db, mock := redismock.NewClientMock()

Callers

nothing calls this directly

Calls 2

LockMethod · 0.95
NewLockerFunction · 0.85

Tested by

no test coverage detected