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

Function TestLocker_ExtendLock_Success

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

Source from the content-addressed store, hash-verified

74}
75
76func TestLocker_ExtendLock_Success(t *testing.T) {
77 db, mock := redismock.NewClientMock()
78 locker := NewLocker(db, "test-key", "test-value")
79
80 // Simulate successful lock extension
81 script := "if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('pexpire', KEYS[1], ARGV[2]) else return 0 end"
82 mock.ExpectEval(script, []string{"test-key"}, "test-value", "5000").SetVal(int64(1))
83
84 err := locker.ExtendLock(context.Background(), 5*time.Second)
85 assert.NoError(t, err)
86 assert.NoError(t, mock.ExpectationsWereMet())
87}
88
89func TestLocker_ExtendLock_Failure(t *testing.T) {
90 db, mock := redismock.NewClientMock()

Callers

nothing calls this directly

Calls 2

ExtendLockMethod · 0.95
NewLockerFunction · 0.85

Tested by

no test coverage detected