diff --git a/src/_utils/_git_secret_tools.sh b/src/_utils/_git_secret_tools.sh index b574bbfc..356985b8 100644 --- a/src/_utils/_git_secret_tools.sh +++ b/src/_utils/_git_secret_tools.sh @@ -128,7 +128,7 @@ function _show_manual_for { # VCS : function _check_ignore { - git check-ignore -q "$1"; + git check-ignore --no-index -q "$1"; echo $? } diff --git a/tests/_test_base.bash b/tests/_test_base.bash index 0ea845a6..c1cb59c3 100644 --- a/tests/_test_base.bash +++ b/tests/_test_base.bash @@ -53,7 +53,7 @@ function install_fixture_key { $SECRETS_GPG_COMMAND --homedir="$FIXTURES_DIR/gpg/${1}" \ --no-permission-warning --output "$public_key" \ - --armor --batch --yes --export "$email" > /dev/null 2>&1 + --armor --batch --yes --export "$email" $GPGTEST --import "$public_key" > /dev/null 2>&1 rm -f "$public_key" } @@ -65,7 +65,7 @@ function install_fixture_full_key { $SECRETS_GPG_COMMAND --homedir="$FIXTURES_DIR/gpg/${1}" \ --no-permission-warning --output "$private_key" --armor \ - --yes --export-secret-key "$email" > /dev/null 2>&1 + --yes --export-secret-key "$email" $GPGTEST --allow-secret-key-import --import "$private_key" > /dev/null 2>&1 @@ -93,7 +93,7 @@ function uninstall_fixture_full_key { local fingerprint="$2" if [[ -z "$fingerprint" ]]; then # see issue_12, fingerprint on `gpg2` has different format: - fingerprint=$(_get_gpg_fingerprint_by_email "$email") + fingerprint=$(get_gpg_fingerprint_by_email "$email") fi $GPGTEST --batch --yes --delete-secret-keys "$fingerprint" > /dev/null 2>&1 diff --git a/tests/test_add.bats b/tests/test_add.bats index e3157484..80228a79 100644 --- a/tests/test_add.bats +++ b/tests/test_add.bats @@ -23,9 +23,9 @@ function teardown { echo "content" > "$TEST_FILE" run git secret add "$TEST_FILE" - rm -f "$TEST_FILE" - [ "$status" -eq 1 ] + + rm -f "$TEST_FILE" } @@ -50,10 +50,10 @@ function teardown { echo "$filename" > ".gitignore" run git secret add "$filename" - rm -f "$filename" ".gitignore" - [ "$status" -eq 0 ] + rm -f "$filename" ".gitignore" + local files_list=$(cat "$SECRETS_DIR_PATHS_MAPPING") [ "$files_list" = "$filename" ] } @@ -69,9 +69,10 @@ function teardown { echo "$TEST_DIR/$TEST_FILE" > ".gitignore" run git secret add "$TEST_DIR/$TEST_FILE" - rm -rf "$TEST_DIR" - [ "$status" -eq 0 ] + [[ "$output" == *"1 items added."* ]] + + rm -rf "$TEST_DIR" } @@ -82,11 +83,11 @@ function teardown { run git secret add "$filename" run git secret add "$filename" - rm -f "$filename" ".gitignore" - [ "$status" -eq 0 ] [ "$output" = "1 items added." ] + rm -f "$filename" ".gitignore" + local files_list=`cat "$SECRETS_DIR_PATHS_MAPPING"` [ "$files_list" = "$filename" ] } @@ -102,8 +103,8 @@ function teardown { echo "$filename2" >> ".gitignore" run git secret add "$filename1" "$filename2" - rm -f "$filename1" "$filename2" ".gitignore" - [ "$status" -eq 0 ] [ "$output" = "2 items added." ] + + rm -f "$filename1" "$filename2" ".gitignore" }