Chromium Code Reviews| 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..ffc6fefd7fd0ab8b80033e18bfde0ac182ce42c2 |
| --- /dev/null |
| +++ b/mmutex/lib/flock_test.go |
| @@ -0,0 +1,29 @@ |
| +// 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" |
| + "io/ioutil" |
| + "os" |
| + "testing" |
| + |
| + . "github.com/smartystreets/goconvey/convey" |
| + |
| + . "github.com/luci/luci-go/common/testing/assertions" |
| +) |
| + |
| +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), ShouldErrLike, fmt.Sprintf("cannot acquire lock on %s because file does not exist", path)) |
|
iannucci
2017/07/12 01:34:59
tbh, "file does not exist" is enough of a substrin
charliea (OOO until 10-5)
2017/07/12 02:17:17
I went with "lock file does not exist"
|
| + }) |
| +} |