mirror of https://github.com/k3s-io/k3s
Browse Source
* Upgraded flock with shared and integration test. Signed-off-by: dereknola <derek.nola@suse.com> Co-authored-by: Brian Downs <brian.downs@gmail.com>pull/3929/head
Derek Nola
3 years ago
committed by
GitHub
2 changed files with 61 additions and 1 deletions
@ -0,0 +1,34 @@
|
||||
package flock_test |
||||
|
||||
import ( |
||||
"testing" |
||||
|
||||
. "github.com/onsi/ginkgo" |
||||
. "github.com/onsi/gomega" |
||||
"github.com/rancher/k3s/pkg/flock" |
||||
) |
||||
|
||||
const lockfile = "/tmp/testlock.test" |
||||
|
||||
var lock int |
||||
var _ = Describe("file locks", func() { |
||||
When("a new exclusive lock is created", func() { |
||||
It("starts up with no problems", func() { |
||||
var err error |
||||
lock, err = flock.Acquire(lockfile) |
||||
Expect(err).ToNot(HaveOccurred()) |
||||
}) |
||||
It("has a write lock on the file", func() { |
||||
Expect(flock.CheckLock(lockfile)).To(BeTrue()) |
||||
}) |
||||
It("release the lock correctly", func() { |
||||
Expect(flock.Release(lock)).To(Succeed()) |
||||
Expect(flock.CheckLock(lockfile)).To(BeFalse()) |
||||
}) |
||||
}) |
||||
}) |
||||
|
||||
func TestFlock(t *testing.T) { |
||||
RegisterFailHandler(Fail) |
||||
RunSpecs(t, "Flock Suite") |
||||
} |
Loading…
Reference in new issue