We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c6c7c77 commit 958d664Copy full SHA for 958d664
1 file changed
flock_internal_test.go
@@ -0,0 +1,30 @@
1
+package flock
2
+
3
+import (
4
+ "io/ioutil"
5
+ "os"
6
+ "testing"
7
+)
8
9
+func Test(t *testing.T) {
10
+ tmpFileFh, err := ioutil.TempFile(os.TempDir(), "go-flock-")
11
+ tmpFileFh.Close()
12
+ tmpFile := tmpFileFh.Name()
13
+ os.Remove(tmpFile)
14
15
+ lock := New(tmpFile)
16
+ locked, err := lock.TryLock()
17
+ if locked == false || err != nil {
18
+ t.Fatal("failed to lock")
19
+ }
20
21
+ newLock := New(tmpFile)
22
+ locked, err = newLock.TryLock()
23
+ if locked != false || err != nil {
24
+ t.Fatal("should have failed locking")
25
26
27
+ if newLock.fh != nil {
28
+ t.Fatal("file handle should have been released and be nil")
29
30
+}
0 commit comments