mirror of
https://github.com/sobolevn/git-secret
synced 2024-11-06 15:20:36 +00:00
9d0a2ac1c1
Changes: 1. Fixes #86, now all variables are accessed as functions 2. Fixes #85, now these use cases are working correctly 3. Fixes #83, now init works relative to `.git` folder 4. Closes #77, zsh-plugin is deprecated 5. Refs #53, done some refactoring to tests 6. Closes #82, added additional information to pull-request template 7. Refs #22, plugins are deprecated 8. Also made a lot of improvments into both code and tests
72 lines
1.5 KiB
Bash
72 lines
1.5 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load _test_base
|
|
|
|
|
|
function setup {
|
|
install_fixture_key "$TEST_DEFAULT_USER"
|
|
install_fixture_key "$TEST_SECOND_USER"
|
|
|
|
set_state_initial
|
|
set_state_git
|
|
set_state_secret_init
|
|
set_state_secret_tell "$TEST_DEFAULT_USER"
|
|
set_state_secret_tell "$TEST_SECOND_USER"
|
|
}
|
|
|
|
|
|
function teardown {
|
|
uninstall_fixture_key "$TEST_DEFAULT_USER"
|
|
uninstall_fixture_key "$TEST_SECOND_USER"
|
|
unset_current_state
|
|
}
|
|
|
|
|
|
@test "run 'whoknows' normally" {
|
|
run git secret whoknows
|
|
[ "$status" -eq 0 ]
|
|
|
|
# Now test the output, both users should be present:
|
|
[[ "$output" == *"$TEST_DEFAULT_USER"* ]]
|
|
[[ "$output" == *"$TEST_SECOND_USER"* ]]
|
|
}
|
|
|
|
|
|
@test "run 'whoknows' in subfolder" {
|
|
if [[ "$BATS_RUNNING_FROM_GIT" -eq 1 ]]; then
|
|
skip "this test is skiped while 'git commmit'"
|
|
fi
|
|
|
|
# Preparations:
|
|
local current_dir=$(pwd)
|
|
local root_dir='test_dir'
|
|
local test_dir="$root_dir/subfolders/case"
|
|
|
|
mkdir -p "$test_dir"
|
|
cd "$test_dir"
|
|
|
|
# Test:
|
|
run git secret whoknows
|
|
[ "$status" -eq 0 ]
|
|
|
|
# Now test the output, both users should be present:
|
|
[[ "$output" == *"$TEST_DEFAULT_USER"* ]]
|
|
[[ "$output" == *"$TEST_SECOND_USER"* ]]
|
|
|
|
# Cleaning up:
|
|
cd "$current_dir"
|
|
rm -r "$root_dir"
|
|
}
|
|
|
|
|
|
@test "run 'whoknows' without any users" {
|
|
# Preparations, removing users:
|
|
local email1=$(test_user_email "$TEST_DEFAULT_USER")
|
|
local email2=$(test_user_email "$TEST_SECOND_USER")
|
|
git secret killperson "$email1" "$email2"
|
|
|
|
# Now whoknows should raise an error: there are no users.
|
|
run git secret whoknows
|
|
[ "$status" -eq 1 ]
|
|
}
|