From b176040a8355383fff37f3e3afdd7f9578e0a4bf Mon Sep 17 00:00:00 2001 From: sobolevn Date: Sun, 29 May 2016 13:56:48 +0300 Subject: [PATCH] Changed the way tests were handling `git-commit`. Since CI was failing. Changed it to set `user.name` and `user.email`. --- tests/_test_base.bash | 14 ++++++++++++-- tests/test_changes.bats | 3 +-- tests/test_tell.bats | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/tests/_test_base.bash b/tests/_test_base.bash index ddf1a052..f62b85c5 100644 --- a/tests/_test_base.bash +++ b/tests/_test_base.bash @@ -14,7 +14,6 @@ TEST_SECRETS_DIR="$BATS_TMPDIR/$SECRETS_DIR" TEST_SECRETS_DIR_PATHS_MAPPING="$BATS_TMPDIR/$SECRETS_DIR_PATHS_MAPPING" TEST_GPG_HOMEDIR="$PWD" -# TEST_TEMP_FILE="$BATS_TMPDIR/test_temp" # GPG-based stuff: : ${SECRETS_GPG_COMMAND:="gpg"} @@ -22,6 +21,7 @@ GPGTEST="$SECRETS_GPG_COMMAND --homedir=$TEST_GPG_HOMEDIR --no-permission-warnin # Personal data: + TEST_DEFAULT_USER="user1" function test_user_password { @@ -34,7 +34,6 @@ function test_user_email { } - # GPG: function _get_gpg_fingerprint_by_email { @@ -103,6 +102,7 @@ function uninstall_fixture_full_key { # Git: + function git_set_config_email { git config --local user.email "$1" } @@ -113,12 +113,22 @@ function git_restore_default_email { } +function git_commit { + git_set_config_email "$1" + git config --local user.name "Your Name" + + git add --all + git commit -m "$2" +} + + function remove_git_repository { rm -rf ".git" } # Git Secret: + function set_state_git { git init > /dev/null 2>&1 } diff --git a/tests/test_changes.bats b/tests/test_changes.bats index 9aff272f..1782d58e 100644 --- a/tests/test_changes.bats +++ b/tests/test_changes.bats @@ -48,8 +48,7 @@ function teardown { @test "run 'changes' with commit" { - git add --all - git commit -m 'initial' + git_commit "$(test_user_email $TEST_DEFAULT_USER)" 'initial' local password=$(test_user_password "$TEST_DEFAULT_USER") echo "new content" >> "$FILE_TO_HIDE" diff --git a/tests/test_tell.bats b/tests/test_tell.bats index d9e52167..da5e1804 100644 --- a/tests/test_tell.bats +++ b/tests/test_tell.bats @@ -4,7 +4,7 @@ load _test_base function setup { - install_fixture_key $TEST_DEFAULT_USER + install_fixture_key "$TEST_DEFAULT_USER" set_state_git set_state_secret_init }