| 12345678910111213141516171819202122232425262728 |
- package trylock_test
- import (
- "testing"
- "time"
- "github.com/labring/aiproxy/core/common/trylock"
- )
- func TestMemLock(t *testing.T) {
- if !trylock.MemLock("", time.Second) {
- t.Error("Expected true, Got false")
- }
- if trylock.MemLock("", time.Second) {
- t.Error("Expected false, Got true")
- }
- if trylock.MemLock("", time.Second) {
- t.Error("Expected false, Got true")
- }
- time.Sleep(time.Second)
- if !trylock.MemLock("", time.Second) {
- t.Error("Expected true, Got false")
- }
- }
|