summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJakob Unterwurzacher2018-06-05 21:02:35 +0200
committerJakob Unterwurzacher2018-06-05 21:02:35 +0200
commite29a81efc3df88b451a4a9464724a952d97b4115 (patch)
tree04efcc8e5cb0101ec12b9a6e3238a874675b97cc /tests
parent98aa9cb1768985b5f4dff33eebf1bc0ebd4a90b3 (diff)
main: make prefixOArgs errors testable
By returning an error instead of calling os.Exit, error cases can be tested easily. Error cases were not tested until now.
Diffstat (limited to 'tests')
-rw-r--r--tests/cli/cli_test.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/cli/cli_test.go b/tests/cli/cli_test.go
index 24bb029..8808742 100644
--- a/tests/cli/cli_test.go
+++ b/tests/cli/cli_test.go
@@ -448,3 +448,15 @@ func TestMultipleOperationFlags(t *testing.T) {
}
}
}
+
+// Test that a missing argument to "-o" triggers exit code 1.
+// See also cli_args_test.go for comprehensive tests of "-o" parsing.
+func TestMissingOArg(t *testing.T) {
+ cmd := exec.Command(test_helpers.GocryptfsBinary, "foo", "bar", "-o")
+ err := cmd.Run()
+ exitCode := test_helpers.ExtractCmdExitCode(err)
+ if exitCode != exitcodes.Usage {
+ t.Fatalf("this should have failed with code %d, but returned %d",
+ exitcodes.Usage, exitCode)
+ }
+}