From e1a627d36a652d96b2f00f229c7075517a5fa3f5 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Sat, 1 Oct 2016 23:07:36 +0300 Subject: [PATCH] Added test to cover #50 Changes: 1. Fixed typo in `add -h` 2. Removed unused function from `usage` --- src/commands/git_secret_add.sh | 2 +- src/commands/git_secret_usage.sh | 13 ------------- tests/test_add.bats | 16 ++++++++++++++++ 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/commands/git_secret_add.sh b/src/commands/git_secret_add.sh index 29da19d1..a9168ae9 100644 --- a/src/commands/git_secret_add.sh +++ b/src/commands/git_secret_add.sh @@ -8,7 +8,7 @@ function add { while getopts "ih" opt; do case "$opt" in i) auto_add=1;; - h) _show_manaul_for "add";; + h) _show_manual_for "add";; esac done diff --git a/src/commands/git_secret_usage.sh b/src/commands/git_secret_usage.sh index 0e468771..2359fbfe 100644 --- a/src/commands/git_secret_usage.sh +++ b/src/commands/git_secret_usage.sh @@ -1,19 +1,6 @@ #!/usr/bin/env bash -function _show_help_usage { - cat <<-EOF -usage: git secret usage -prints all the available commands. - -options: - -h shows this help. - -EOF - exit 0 -} - - function usage { OPTIND=1 diff --git a/tests/test_add.bats b/tests/test_add.bats index b65944d3..e3157484 100644 --- a/tests/test_add.bats +++ b/tests/test_add.bats @@ -59,6 +59,22 @@ function teardown { } +@test "run 'add' for file in subdirectory" { + local TEST_FILE='test_file' + local TEST_DIR='test_dir' + + mkdir "$TEST_DIR" + touch "$TEST_DIR/$TEST_FILE" + echo "content" > "$TEST_DIR/$TEST_FILE" + echo "$TEST_DIR/$TEST_FILE" > ".gitignore" + + run git secret add "$TEST_DIR/$TEST_FILE" + rm -rf "$TEST_DIR" + + [ "$status" -eq 0 ] +} + + @test "run 'add' twice for one file" { local filename="local_file" echo "content" > "$filename"