Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Unified Diff: mmutex/lib/flock_test.go

Issue 2980603003: Flesh out the mmutex binary wrapper and test for existence of lockfile (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« mmutex/lib/flock.go ('K') | « mmutex/lib/flock.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mmutex/lib/flock_test.go
diff --git a/mmutex/lib/flock_test.go b/mmutex/lib/flock_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..144d6925c9c16c0d001fb4b12a36570cf254c99e
--- /dev/null
+++ b/mmutex/lib/flock_test.go
@@ -0,0 +1,26 @@
+// Copyright 2017 The LUCI Authors. All rights reserved.
+// Use of this source code is governed under the Apache License, Version 2.0
+// that can be found in the LICENSE file.
+
+package lib
+
+import (
+ "fmt"
+ . "github.com/smartystreets/goconvey/convey"
+ "io/ioutil"
+ "os"
+ "testing"
iannucci 2017/07/11 20:52:15 imports should be separated basically like: <st
charliea (OOO until 10-5) 2017/07/11 23:26:16 Done.
+)
+
+func TestAcquireExclusiveLock(t *testing.T) {
+ lockDir, err := ioutil.TempDir("/tmp", "")
+ if err != nil {
+ t.Error("received error creating temporary testing directory")
+ }
+ defer os.Remove(lockDir)
+ path := lockDir + ".lock"
+
+ Convey("AcquireExclusiveLock errors if lock file doesn't exist", t, func(c C) {
+ So(AcquireExclusiveLock(path).Error(), ShouldEqual, fmt.Sprintf("cannot acquire lock on %s because file does not exist", path))
iannucci 2017/07/11 20:52:15 add an import: . "github.com/luci/luci-go/commo
charliea (OOO until 10-5) 2017/07/11 23:26:16 Done.
+ })
+}
« mmutex/lib/flock.go ('K') | « mmutex/lib/flock.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698