github.com/diggerhq/digger/libs@v0.0.0-20240604170430-9d61cdf01cc5/locking/mock.go (about) 1 package locking 2 3 type MockLock struct { 4 MapLock map[string]int 5 } 6 7 func (lock *MockLock) Lock(transactionId int, resource string) (bool, error) { 8 if lock.MapLock == nil { 9 lock.MapLock = make(map[string]int) 10 } 11 lock.MapLock[resource] = transactionId 12 return true, nil 13 } 14 15 func (lock *MockLock) Unlock(resource string) (bool, error) { 16 delete(lock.MapLock, resource) 17 return true, nil 18 } 19 20 func (lock *MockLock) GetLock(resource string) (*int, error) { 21 result, ok := lock.MapLock[resource] 22 if ok { 23 return &result, nil 24 } 25 return nil, nil 26 }