summaryrefslogtreecommitdiff
path: root/tests/integration_tests
diff options
context:
space:
mode:
authorJakob Unterwurzacher2016-06-16 21:06:03 +0200
committerJakob Unterwurzacher2016-06-16 21:27:01 +0200
commit305e9c1045f0546967bfbd2d10f13a28b6227a76 (patch)
tree1f4790963e332c8607a66f6b021ce37c672ab62f /tests/integration_tests
parentc76c952c192f5378eb713f4f3435de29af0f7922 (diff)
tests: add InitFS helper
Diffstat (limited to 'tests/integration_tests')
-rw-r--r--tests/integration_tests/cli_test.go65
1 files changed, 11 insertions, 54 deletions
diff --git a/tests/integration_tests/cli_test.go b/tests/integration_tests/cli_test.go
index 0e88581..ae6ef7f 100644
--- a/tests/integration_tests/cli_test.go
+++ b/tests/integration_tests/cli_test.go
@@ -3,7 +3,6 @@ package integration_tests
// Test CLI operations like "-init", "-password" etc
import (
- "io/ioutil"
"os"
"os/exec"
"path/filepath"
@@ -17,18 +16,8 @@ import (
// Test -init flag
func TestInit(t *testing.T) {
- dir, err := ioutil.TempDir(test_helpers.TmpDir, "TestInit")
- if err != nil {
- t.Fatal(err)
- }
- cmd := exec.Command(test_helpers.GocryptfsBinary, "-q", "-init", "-extpass", "echo test", "-scryptn=10", dir)
- cmd.Stdout = os.Stdout
- cmd.Stderr = os.Stderr
- err = cmd.Run()
- if err != nil {
- t.Fatal(err)
- }
- _, err = os.Stat(filepath.Join(dir, configfile.ConfDefaultName))
+ dir := test_helpers.InitFS(t)
+ _, err := os.Stat(filepath.Join(dir, configfile.ConfDefaultName))
if err != nil {
t.Fatal(err)
}
@@ -37,22 +26,12 @@ func TestInit(t *testing.T) {
// Test -passwd flag
func TestPasswd(t *testing.T) {
// Create FS
- dir, err := ioutil.TempDir(test_helpers.TmpDir, "TestPasswd")
- if err != nil {
- t.Fatal(err)
- }
- cmd := exec.Command(test_helpers.GocryptfsBinary, "-q", "-init", "-extpass", "echo test", "-scryptn=10", dir)
- cmd.Stdout = os.Stdout
- cmd.Stderr = os.Stderr
- err = cmd.Run()
- if err != nil {
- t.Fatal(err)
- }
+ dir := test_helpers.InitFS(t)
// Change password using "-extpass"
- cmd = exec.Command(test_helpers.GocryptfsBinary, "-q", "-passwd", "-extpass", "echo test", dir)
+ cmd := exec.Command(test_helpers.GocryptfsBinary, "-q", "-passwd", "-extpass", "echo test", dir)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
- err = cmd.Run()
+ err := cmd.Run()
if err != nil {
t.Error(err)
}
@@ -81,21 +60,10 @@ func TestPasswd(t *testing.T) {
// Test -init & -config flag
func TestInitConfig(t *testing.T) {
- dir := test_helpers.TmpDir + "TestInitConfig/"
config := test_helpers.TmpDir + "TestInitConfig.conf"
- err := os.Mkdir(dir, 0777)
- if err != nil {
- t.Fatal(err)
- }
- cmd := exec.Command(test_helpers.GocryptfsBinary, "-q", "-init", "-extpass", "echo test",
- "-config", config, "-scryptn=10", dir)
- cmd.Stdout = os.Stdout
- cmd.Stderr = os.Stderr
- err = cmd.Run()
- if err != nil {
- t.Fatal(err)
- }
- _, err = os.Stat(config)
+ dir := test_helpers.InitFS(t, "-config="+config)
+
+ _, err := os.Stat(config)
if err != nil {
t.Fatal(err)
}
@@ -113,20 +81,9 @@ func TestInitConfig(t *testing.T) {
// Test -init -plaintextnames
func TestInitPlaintextNames(t *testing.T) {
- dir := test_helpers.TmpDir + "TestInitPlaintextNames/"
- err := os.Mkdir(dir, 0777)
- if err != nil {
- t.Fatal(err)
- }
- cmd := exec.Command(test_helpers.GocryptfsBinary, "-q", "-init", "-extpass", "echo test",
- "-scryptn=10", "-plaintextnames", dir)
- cmd.Stdout = os.Stdout
- cmd.Stderr = os.Stderr
- err = cmd.Run()
- if err != nil {
- t.Fatal(err)
- }
- _, err = os.Stat(dir + configfile.ConfDefaultName)
+ dir := test_helpers.InitFS(t, "-plaintextnames")
+ dir = dir + "/"
+ _, err := os.Stat(dir + configfile.ConfDefaultName)
if err != nil {
t.Fatal(err)
}