From 84f5cffec908479ac0c32d66839aca5a8b0503ec Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 24 Apr 2014 17:55:34 +0200 Subject: tests: test for spaces --- tests/t0020-show-tests.sh | 5 +++++ tests/t0050-mv-tests.sh | 16 ++++++++-------- tests/t0060-rm-tests.sh | 7 +++++++ 3 files changed, 20 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/t0020-show-tests.sh b/tests/t0020-show-tests.sh index e55e574..a4b782f 100755 --- a/tests/t0020-show-tests.sh +++ b/tests/t0020-show-tests.sh @@ -10,6 +10,11 @@ test_expect_success 'Test "show" command' ' "$PASS" show cred1 ' +test_expect_success 'Test "show" command with spaces' ' + "$PASS" insert -e "I am a cred with lots of spaces"<<<"BLAH!!" && + [[ $("$PASS" show "I am a cred with lots of spaces") == "BLAH!!" ]] +' + test_expect_success 'Test "show" of nonexistant password' ' test_must_fail "$PASS" show cred2 ' diff --git a/tests/t0050-mv-tests.sh b/tests/t0050-mv-tests.sh index 6561286..3ec7c2a 100755 --- a/tests/t0050-mv-tests.sh +++ b/tests/t0050-mv-tests.sh @@ -20,24 +20,24 @@ test_expect_success 'Directory creation' ' ' test_expect_success 'Directory creation with file rename and empty directory removal' ' - "$PASS" mv directory/cred2 newdirectory/cred && - [[ -d $PASSWORD_STORE_DIR/newdirectory && -e $PASSWORD_STORE_DIR/newdirectory/cred.gpg && ! -e $PASSWORD_STORE_DIR/directory ]] + "$PASS" mv directory/cred2 "new directory with spaces"/cred && + [[ -d $PASSWORD_STORE_DIR/"new directory with spaces" && -e $PASSWORD_STORE_DIR/"new directory with spaces"/cred.gpg && ! -e $PASSWORD_STORE_DIR/directory ]] ' test_expect_success 'Directory rename' ' - "$PASS" mv newdirectory anotherdirectory && - [[ -d $PASSWORD_STORE_DIR/anotherdirectory && -e $PASSWORD_STORE_DIR/anotherdirectory/cred.gpg && ! -e $PASSWORD_STORE_DIR/newdirectory ]] + "$PASS" mv "new directory with spaces" anotherdirectory && + [[ -d $PASSWORD_STORE_DIR/anotherdirectory && -e $PASSWORD_STORE_DIR/anotherdirectory/cred.gpg && ! -e $PASSWORD_STORE_DIR/"new directory with spaces" ]] ' test_expect_success 'Directory move into new directory' ' - "$PASS" mv anotherdirectory newdirectory/ && - [[ -d $PASSWORD_STORE_DIR/newdirectory/anotherdirectory && -e $PASSWORD_STORE_DIR/newdirectory/anotherdirectory/cred.gpg && ! -e $PASSWORD_STORE_DIR/anotherdirectory ]] + "$PASS" mv anotherdirectory "new directory with spaces"/ && + [[ -d $PASSWORD_STORE_DIR/"new directory with spaces"/anotherdirectory && -e $PASSWORD_STORE_DIR/"new directory with spaces"/anotherdirectory/cred.gpg && ! -e $PASSWORD_STORE_DIR/anotherdirectory ]] ' test_expect_success 'Multi-directory creation and multi-directory empty removal' ' - "$PASS" mv newdirectory/anotherdirectory/cred new1/new2/new3/new4/thecred && + "$PASS" mv "new directory with spaces"/anotherdirectory/cred new1/new2/new3/new4/thecred && "$PASS" mv new1/new2/new3/new4/thecred cred && - [[ ! -d $PASSWORD_STORE_DIR/newdirectory/anotherdirectory && ! -d $PASSWORD_STORE_DIR/new1/new2/new3/new4 && -e $PASSWORD_STORE_DIR/cred.gpg ]] + [[ ! -d $PASSWORD_STORE_DIR/"new directory with spaces"/anotherdirectory && ! -d $PASSWORD_STORE_DIR/new1/new2/new3/new4 && -e $PASSWORD_STORE_DIR/cred.gpg ]] ' test_expect_success 'Password made it until the end' ' diff --git a/tests/t0060-rm-tests.sh b/tests/t0060-rm-tests.sh index 29fa34a..58f55f3 100755 --- a/tests/t0060-rm-tests.sh +++ b/tests/t0060-rm-tests.sh @@ -11,6 +11,13 @@ test_expect_success 'Test "rm" command' ' [[ ! -e $PASSWORD_STORE_DIR/cred1.gpg ]] ' +test_expect_success 'Test "rm" command with spaces' ' + "$PASS" generate "hello i have spaces" 43 && + [[ -e $PASSWORD_STORE_DIR/"hello i have spaces".gpg ]] && + "$PASS" rm "hello i have spaces" && + [[ ! -e $PASSWORD_STORE_DIR/"hello i have spaces".gpg ]] +' + test_expect_success 'Test "rm" of non-existent password' ' test_must_fail "$PASS" rm does-not-exist ' -- cgit v1.2.3