diff --git a/tests/_test_base.bash b/tests/_test_base.bash index bbf14504..fd1ee127 100644 --- a/tests/_test_base.bash +++ b/tests/_test_base.bash @@ -37,6 +37,15 @@ TEST_DEFAULT_USER="user1" TEST_SECOND_USER="user2" # shellcheck disable=2034 TEST_ATTACKER_USER="attacker1" # shellcheck disable=2034 +#TEST_DEFAULT_FILENAME="file_one" # no spaces +#TEST_SECOND_FILENAME="file_two" # no spaces +#TEST_THIRD_FILENAME="file_three" # no spaces + +TEST_DEFAULT_FILENAME="space file" # has spaces +TEST_SECOND_FILENAME="space file two" # has spaces +TEST_THIRD_FILENAME="space file three" # has spaces + + function test_user_password { # It was set on key creation: echo "${1}pass" diff --git a/tests/test_add.bats b/tests/test_add.bats index 27c0a0c6..668c271b 100644 --- a/tests/test_add.bats +++ b/tests/test_add.bats @@ -21,7 +21,7 @@ function teardown { @test "run 'add' normally" { # Preparations: - local filename="local_file" + local filename="$TEST_DEFAULT_FILENAME" echo "content" > "$filename" echo "$filename" > ".gitignore" @@ -41,7 +41,7 @@ function teardown { @test "run 'add' for unignored file" { - local test_file='test_file' + local test_file="$TEST_DEFAULT_FILENAME" touch "$test_file" echo "content" > "$test_file" @@ -53,7 +53,7 @@ function teardown { @test "run 'add' for unignored file with '-i'" { - local test_file='test_file.auto_ignore' + local test_file='test_file.auto_ignore' # TODO - paramaterize filename touch "$test_file" echo "content" > "$test_file" @@ -112,7 +112,7 @@ function teardown { local root='test_dir' local node="$root/node" local sibling="$root/sibling" - local test_file="$node/test_file" + local test_file="$node/$TEST_DEFAULT_FILENAME" local current_dir=$(pwd) mkdir -p "$node" @@ -124,7 +124,7 @@ function teardown { cd "$sibling" # Testing: - run git secret add "../node/test_file" + run git secret add "../node/$TEST_DEFAULT_FILENAME" [ "$status" -eq 0 ] [[ "$output" == *"1 item(s) added."* ]] @@ -143,7 +143,7 @@ function teardown { @test "run 'add' for file in subfolder" { # Preparations: - local test_file='test_file' + local test_file="$TEST_DEFAULT_FILENAME" local test_dir='test_dir' mkdir -p "$test_dir" @@ -163,7 +163,7 @@ function teardown { @test "run 'add' twice for one file" { # Preparations: - local filename="local_file" + local filename="$TEST_DEFAULT_FILENAME" echo "content" > "$filename" echo "$filename" > ".gitignore" @@ -187,11 +187,11 @@ function teardown { @test "run 'add' for multiple files" { # Preparations: - local filename1="local_file1" + local filename1="$TEST_DEFAULT_FILENAME" echo "content1" > "$filename1" echo "$filename1" > ".gitignore" - local filename2="local_file2" + local filename2="$TEST_SECOND_FILENAME" echo "content2" > "$filename2" echo "$filename2" >> ".gitignore" diff --git a/tests/test_cat.bats b/tests/test_cat.bats index 1c17efe0..eab781fd 100644 --- a/tests/test_cat.bats +++ b/tests/test_cat.bats @@ -2,7 +2,7 @@ load _test_base -FILE_TO_HIDE="file_to_hide" +FILE_TO_HIDE="$TEST_DEFAULT_FILENAME" FILE_CONTENTS="hidden content юникод" FINGERPRINT="" diff --git a/tests/test_changes.bats b/tests/test_changes.bats index 1a26bd85..92cd52ab 100644 --- a/tests/test_changes.bats +++ b/tests/test_changes.bats @@ -2,8 +2,8 @@ load _test_base -FILE_TO_HIDE="file_to_hide" -SECOND_FILE_TO_HIDE="second_file_to_hide" +FILE_TO_HIDE="$TEST_DEFAULT_FILENAME" +SECOND_FILE_TO_HIDE="$TEST_SECOND_FILENAME" FILE_CONTENTS="hidden content юникод" FINGERPRINT="" @@ -54,7 +54,7 @@ function teardown { @test "run 'changes' with hidden file missing" { local password=$(test_user_password "$TEST_DEFAULT_USER") - local encrypted_file=$(_get_encrypted_filename $FILE_TO_HIDE) + local encrypted_file=$(_get_encrypted_filename "$FILE_TO_HIDE") rm "$encrypted_file" run git secret changes -d "$TEST_GPG_HOMEDIR" -p "$password" "$FILE_TO_HIDE" diff --git a/tests/test_clean.bats b/tests/test_clean.bats index 45dc6550..872bbcd5 100644 --- a/tests/test_clean.bats +++ b/tests/test_clean.bats @@ -2,8 +2,8 @@ load _test_base -FIRST_FILE="file_to_hide1" -SECOND_FILE="file_to_hide2" +FIRST_FILE="$TEST_DEFAULT_FILENAME" +SECOND_FILE="$TEST_SECOND_FILENAME" FOLDER="somedir" FILE_IN_FOLDER="${FOLDER}/file_to_hide3" diff --git a/tests/test_hide.bats b/tests/test_hide.bats index 9fdea916..baf82a1c 100644 --- a/tests/test_hide.bats +++ b/tests/test_hide.bats @@ -2,7 +2,7 @@ load _test_base -FILE_TO_HIDE="file_to_hide" +FILE_TO_HIDE="$TEST_DEFAULT_FILENAME" FILE_CONTENTS="hidden content юникод" @@ -61,7 +61,7 @@ function teardown { @test "run 'hide' with missing file" { # Preparations: - local second_file="second_file.txt" + local second_file="$TEST_SECOND_FILENAME" local second_content="some content" set_state_secret_add "$second_file" "$second_content" @@ -77,7 +77,7 @@ function teardown { @test "run 'hide' with multiple files" { # Preparations: - local second_file="second_file.txt" + local second_file="$TEST_SECOND_FILENAME" local second_content="some content" set_state_secret_add "$second_file" "$second_content" @@ -183,7 +183,7 @@ function teardown { # Preparations: local root_dir='test_sub_dir' mkdir -p "$root_dir" - local second_file="$root_dir/second_file.txt" + local second_file="$root_dir/$TEST_SECOND_FILENAME" local second_content="some content" set_state_secret_add "$second_file" "$second_content" diff --git a/tests/test_reveal.bats b/tests/test_reveal.bats index 87a6bf36..f8bcba9f 100644 --- a/tests/test_reveal.bats +++ b/tests/test_reveal.bats @@ -2,7 +2,7 @@ load _test_base -FILE_TO_HIDE="file_to_hide" +FILE_TO_HIDE="$TEST_DEFAULT_FILENAME" FILE_CONTENTS="hidden content юникод" FINGERPRINT="" diff --git a/tests/test_reveal_filename.bats b/tests/test_reveal_filename.bats index 4c5c0334..4d81131e 100644 --- a/tests/test_reveal_filename.bats +++ b/tests/test_reveal_filename.bats @@ -2,7 +2,7 @@ load _test_base -FILE_TO_HIDE="file_to_hide" +FILE_TO_HIDE="$TEST_DEFAULT_FILENAME" FILE_CONTENTS="hidden content юникод" FINGERPRINT=""