22 lines
267 B
Go
22 lines
267 B
Go
|
package pid
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
func TestPidLock_Lock(t *testing.T) {
|
||
|
name := "./.pid"
|
||
|
|
||
|
lock := NewPidLock(name)
|
||
|
err := lock.Lock()
|
||
|
defer func(lock *PidLock) {
|
||
|
lock.UnLock()
|
||
|
}(lock)
|
||
|
|
||
|
if err != nil {
|
||
|
t.Fatal(t)
|
||
|
}
|
||
|
time.Sleep(10 * time.Second)
|
||
|
}
|