MCPcopy Create free account
hub / github.com/cloudbase/garm / TestTryLock

Method TestTryLock

locking/local_locker_test.go:193–216  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

191}
192
193func (l *LockerTestSuite) TestTryLock() {
194 locked := TryLock("test", "test-identifier")
195 l.Require().True(locked)
196 mux, ok := l.mux.muxes.Load("test")
197 l.Require().True(ok)
198 keyMux := mux.(*lockWithIdent)
199 l.Require().Equal("test-identifier", keyMux.ident)
200
201 locked = TryLock("test", "another-identifier2")
202 l.Require().False(locked)
203 mux, ok = l.mux.muxes.Load("test")
204 l.Require().True(ok)
205 keyMux = mux.(*lockWithIdent)
206 l.Require().Equal("test-identifier", keyMux.ident)
207
208 Unlock("test", true)
209 locked = TryLock("test", "another-identifier2")
210 l.Require().True(locked)
211 mux, ok = l.mux.muxes.Load("test")
212 l.Require().True(ok)
213 keyMux = mux.(*lockWithIdent)
214 l.Require().Equal("another-identifier2", keyMux.ident)
215 Unlock("test", true)
216}
217
218func (l *LockerTestSuite) TestLockedBy() {
219 Lock("test", "test-identifier")

Callers

nothing calls this directly

Calls 2

TryLockFunction · 0.85
UnlockFunction · 0.85

Tested by

no test coverage detected