27 lines
472 B
Go
27 lines
472 B
Go
package ari
|
|
|
|
import (
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestLockFile(t *testing.T) {
|
|
path := filepath.Join(t.TempDir(), "listener.lock")
|
|
first, err := AcquireLock(path)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if second, err := AcquireLock(path); err == nil {
|
|
_ = second.Release()
|
|
t.Fatal("second lock should fail")
|
|
}
|
|
if err := first.Release(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
third, err := AcquireLock(path)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
_ = third.Release()
|
|
}
|