diff options
author | Jakob Unterwurzacher | 2017-05-07 22:15:01 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2017-05-07 22:16:22 +0200 |
commit | d5adde1eeb13ba377f7c05b9f21893c01f61ec16 (patch) | |
tree | 011813ca5afd81ae6311bb007f5dc10ef69b2e7a /tests | |
parent | ad7942f434fea567f24458e67a0919291b5ec8dd (diff) |
exitcodes: pull all exit code definitions into the package
This commit defines all exit codes in one place in the exitcodes
package.
Also, it adds a test to verify the exit code on incorrect
password, which is what SiriKali cares about the most.
Fixes https://github.com/rfjakob/gocryptfs/issues/77 .
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cli/cli_test.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/cli/cli_test.go b/tests/cli/cli_test.go index cce7fa0..905a890 100644 --- a/tests/cli/cli_test.go +++ b/tests/cli/cli_test.go @@ -10,6 +10,7 @@ import ( "testing" "github.com/rfjakob/gocryptfs/internal/configfile" + "github.com/rfjakob/gocryptfs/internal/exitcodes" "github.com/rfjakob/gocryptfs/tests/test_helpers" ) @@ -316,3 +317,16 @@ func TestInitTrailingGarbage(t *testing.T) { } } } + +// TestPasswordIncorrect makes sure the correct exit code is used when the password +// was incorrect +func TestPasswordIncorrect(t *testing.T) { + cDir := test_helpers.InitFS(t) + pDir := cDir + ".mnt" + err := test_helpers.Mount(cDir, pDir, false, "-extpass", "echo WRONG", "-wpanic=false") + // vvvvvvvvvvvvvv OMG vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv + exitCode := err.(*exec.ExitError).Sys().(syscall.WaitStatus).ExitStatus() + if exitCode != exitcodes.PasswordIncorrect { + t.Errorf("want=%d, got=%d", exitcodes.PasswordIncorrect, exitCode) + } +} |