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

Function TestLocker_Unlock_Success

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

Source from the content-addressed store, hash-verified

48}
49
50func TestLocker_Unlock_Success(t *testing.T) {
51 db, mock := redismock.NewClientMock()
52 locker := NewLocker(db, "test-key", "test-value")
53
54 // Simulate a successful unlock
55 script := "if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('del', KEYS[1]) else return 0 end"
56 mock.ExpectEval(script, []string{"test-key"}, "test-value").SetVal(int64(1))
57
58 err := locker.Unlock(context.Background())
59 assert.NoError(t, err)
60 assert.NoError(t, mock.ExpectationsWereMet())
61}
62
63func TestLocker_Unlock_Failure(t *testing.T) {
64 db, mock := redismock.NewClientMock()

Callers

nothing calls this directly

Calls 2

UnlockMethod · 0.95
NewLockerFunction · 0.85

Tested by

no test coverage detected