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

Function TestLocker_ExtendLock_Failure

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

Source from the content-addressed store, hash-verified

87}
88
89func TestLocker_ExtendLock_Failure(t *testing.T) {
90 db, mock := redismock.NewClientMock()
91 locker := NewLocker(db, "test-key", "test-value")
92
93 // Simulate failed lock extension (either lock expired or not the holder)
94 script := "if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('pexpire', KEYS[1], ARGV[2]) else return 0 end"
95 mock.ExpectEval(script, []string{"test-key"}, "test-value", "5000").SetVal(int64(0))
96
97 err := locker.ExtendLock(context.Background(), 5*time.Second)
98 assert.EqualError(t, err, "lock extension failed for key test-key, either lock expired or you're not the holder")
99 assert.NoError(t, mock.ExpectationsWereMet())
100}
101
102func TestLocker_WaitLock_Success(t *testing.T) {
103 db, mock := redismock.NewClientMock()

Callers

nothing calls this directly

Calls 2

ExtendLockMethod · 0.95
NewLockerFunction · 0.85

Tested by

no test coverage detected