aboutsummaryrefslogtreecommitdiff
path: root/integration_tests/example_filesystems_test.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2015-11-15 15:05:15 +0100
committerJakob Unterwurzacher2015-11-15 15:05:15 +0100
commit40882c6e49186510a8adc6ae4b41a879c5d3278f (patch)
tree789510deb01d2a1fa7db5bd0d44f998b11860399 /integration_tests/example_filesystems_test.go
parent296bdf3af21a8964dcb884ff41ea7556cc811e9a (diff)
tests: add example_filesystems, test password and -masterkey mount
Diffstat (limited to 'integration_tests/example_filesystems_test.go')
-rw-r--r--integration_tests/example_filesystems_test.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/integration_tests/example_filesystems_test.go b/integration_tests/example_filesystems_test.go
new file mode 100644
index 0000000..b208d39
--- /dev/null
+++ b/integration_tests/example_filesystems_test.go
@@ -0,0 +1,46 @@
+package integration_tests
+
+// Mount example filesystems and check that the file "status.txt" is there
+
+import (
+ "io/ioutil"
+ "os"
+ "testing"
+)
+
+const statusTxtContent = "It works!\n"
+
+// checkStatusTxt - read file "filename" and verify that it contains
+// "It works!\n"
+func checkStatusTxt(t *testing.T, filename string) {
+ contentBytes, err := ioutil.ReadFile(filename)
+ if err != nil {
+ t.Error(err)
+ }
+ content := string(contentBytes)
+ if content != statusTxtContent {
+ t.Errorf("Unexpected content: %s\n", content)
+ }
+}
+
+// Test example_filesystems/normal
+// with password mount and -masterkey mount
+func TestExampleFsNormal(t *testing.T) {
+ pDir := tmpDir + "TestExampleFsNormal/"
+ cDir := "example_filesystems/normal"
+ err := os.Mkdir(pDir, 0777)
+ if err != nil {
+ t.Fatal(err)
+ }
+ mount(cDir, pDir, "-extpass", "echo test")
+ checkStatusTxt(t, pDir + "status.txt")
+ unmount(pDir)
+ mount(cDir, pDir, "-masterkey", "74676e34-0b47c145-00dac61a-17a92316-"+
+ "bb57044c-e205b71f-65f4fdca-7cabd4b3")
+ checkStatusTxt(t, pDir + "status.txt")
+ unmount(pDir)
+ err = os.Remove(pDir)
+ if err != nil {
+ t.Error(err)
+ }
+}