Skip to content

Commit

Permalink
modified: funcs_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
nbari committed Jul 22, 2016
1 parent c1b54d9 commit acb652f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions funcs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,25 @@ func TestWritePid(t *testing.T) {
t.Error(e)
}
}

func TestLockNonexistent(t *testing.T) {
err := Lock("/dev/null/nonexistent")
if err == nil {
t.Error("Expecting error")
}
}
func TestLock(t *testing.T) {
tmpfile, err := ioutil.TempFile("", "TestLock")
if err != nil {
t.Error(err)
}
defer os.Remove(tmpfile.Name()) // clean up
err = Lock(tmpfile.Name())
if err != nil {
t.Error(err)
}
err = Lock(tmpfile.Name())
if err == nil {
t.Error("Expecting error")
}
}

0 comments on commit acb652f

Please sign in to comment.