upda/server/service_lock_mem_test.go
Varakh 165b992629
All checks were successful
/ build (push) Successful in 3m11s
feature(locking): add proper locking and overhaul existing locking service (#34)
Reviewed-on: #34
Co-authored-by: Varakh <varakh@varakh.de>
Co-committed-by: Varakh <varakh@varakh.de>
2024-05-24 00:54:35 +02:00

29 lines
548 B
Go

package server
import (
"context"
"github.com/stretchr/testify/assert"
"testing"
"time"
)
const (
testLockName = "test_lock"
)
func TestLockExpiresAndCannotBeReleased(t *testing.T) {
a := assert.New(t)
s := newLockMemService()
ctx := context.Background()
lock, lockErr := s.lockWithOptions(ctx, testLockName, withAppLockOptionExpiry(250*time.Millisecond))
a.Nil(lockErr)
a.NotNil(lock)
time.Sleep(251 * time.Millisecond)
unlockErr := lock.unlock(ctx)
a.NotNil(unlockErr)
a.ErrorContains(unlockErr, "could not release lock")
}