t0050-mv-tests.sh (2038B)
1 #!/usr/bin/env bash 2 3 test_description='Test mv command' 4 cd "$(dirname "$0")" 5 . ./setup.sh 6 7 INITIAL_PASSWORD="bla bla bla will we make it!!" 8 9 test_expect_success 'Basic move command' ' 10 "$PASS" init $KEY1 && 11 "$PASS" git init && 12 "$PASS" insert -e cred1 <<<"$INITIAL_PASSWORD" && 13 "$PASS" mv cred1 cred2 && 14 [[ -e $PASSWORD_STORE_DIR/cred2.gpg && ! -e $PASSWORD_STORE_DIR/cred1.gpg ]] 15 ' 16 17 test_expect_success 'Directory creation' ' 18 "$PASS" mv cred2 directory/ && 19 [[ -d $PASSWORD_STORE_DIR/directory && -e $PASSWORD_STORE_DIR/directory/cred2.gpg ]] 20 ' 21 22 test_expect_success 'Directory creation with file rename and empty directory removal' ' 23 "$PASS" mv directory/cred2 "new directory with spaces"/cred && 24 [[ -d $PASSWORD_STORE_DIR/"new directory with spaces" && -e $PASSWORD_STORE_DIR/"new directory with spaces"/cred.gpg && ! -e $PASSWORD_STORE_DIR/directory ]] 25 ' 26 27 test_expect_success 'Directory rename' ' 28 "$PASS" mv "new directory with spaces" anotherdirectory && 29 [[ -d $PASSWORD_STORE_DIR/anotherdirectory && -e $PASSWORD_STORE_DIR/anotherdirectory/cred.gpg && ! -e $PASSWORD_STORE_DIR/"new directory with spaces" ]] 30 ' 31 32 test_expect_success 'Directory move into new directory' ' 33 "$PASS" mv anotherdirectory "new directory with spaces"/ && 34 [[ -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 ]] 35 ' 36 37 test_expect_success 'Multi-directory creation and multi-directory empty removal' ' 38 "$PASS" mv "new directory with spaces"/anotherdirectory/cred new1/new2/new3/new4/thecred && 39 "$PASS" mv new1/new2/new3/new4/thecred cred && 40 [[ ! -d $PASSWORD_STORE_DIR/"new directory with spaces"/anotherdirectory && ! -d $PASSWORD_STORE_DIR/new1/new2/new3/new4 && -e $PASSWORD_STORE_DIR/cred.gpg ]] 41 ' 42 43 test_expect_success 'Password made it until the end' ' 44 [[ $("$PASS" show cred) == "$INITIAL_PASSWORD" ]] 45 ' 46 47 test_expect_success 'Git is consistent' ' 48 [[ -z $(git status --porcelain 2>&1) ]] 49 ' 50 51 test_done