From 434ce50db38e78f7e2a67af07cb92d8829fdfdf6 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Thu, 6 Oct 2016 22:41:13 +0200 Subject: main: add "-nonempty" option --- tests/normal/cli_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests/normal') diff --git a/tests/normal/cli_test.go b/tests/normal/cli_test.go index f0e160d..6691822 100644 --- a/tests/normal/cli_test.go +++ b/tests/normal/cli_test.go @@ -3,6 +3,7 @@ package normal // Test CLI operations like "-init", "-password" etc import ( + "io/ioutil" "os" "os/exec" "testing" @@ -146,3 +147,24 @@ func TestRo(t *testing.T) { t.Errorf("Create should have failed") } } + +// Test "-nonempty" +func TestNonempty(t *testing.T) { + dir := test_helpers.InitFS(t) + mnt := dir + ".mnt" + err := os.Mkdir(mnt, 0700) + if err != nil { + t.Fatal(err) + } + err = ioutil.WriteFile(mnt+"/somefile", []byte("xyz"), 0600) + if err != nil { + t.Fatal(err) + } + err = test_helpers.Mount(dir, mnt, false, "-extpass=echo test") + if err == nil { + t.Errorf("Mounting over a file should fail per default") + } + // Should work with "-nonempty" + test_helpers.MountOrFatal(t, dir, mnt, "-nonempty", "-extpass=echo test") + test_helpers.UnmountPanic(mnt) +} -- cgit v1.2.3