From ec37d7914bd81e7626b454eef88dace1b3e7fc98 Mon Sep 17 00:00:00 2001 From: Kevin Zhuang Date: Tue, 7 Jul 2020 14:58:43 +1000 Subject: [PATCH] test(flog): update flog test --- scripts/flog | 10 +++++----- tests/flog.bats | 12 ++---------- tests/fzf | 6 +++--- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/scripts/flog b/scripts/flog index 89711ee..21bf562 100755 --- a/scripts/flog +++ b/scripts/flog @@ -59,7 +59,7 @@ function draw_menu() { menu="${menu}checkout: checkout the selected commit\n" menu="${menu}exit: quit dotbare flog" message=$( - /usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" \ + git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" \ log --format=%B -n 1 "${selected_commit}" ) header="commit ${selected_commit}: ${message}" @@ -130,19 +130,19 @@ fi case "${selected_action}" in revert) - /usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" \ + git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" \ revert "${selected_commit}" ;; reset) - /usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" \ + git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" \ reset "${selected_commit}" ;; edit) - /usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" \ + git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" \ rebase -i "${selected_commit}"~ ;; checkout) - /usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" \ + git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" \ checkout "${selected_commit}" ;; exit) diff --git a/tests/flog.bats b/tests/flog.bats index 1f7b58c..e237907 100755 --- a/tests/flog.bats +++ b/tests/flog.bats @@ -30,20 +30,12 @@ reset() { [ "${lines[0]}" = "Invalid option: -p" ] } -@test "flog check routing" { - if ! "${BATS_TEST_DIRNAME}"/../dotbare log &>/dev/null; then - skip - fi +@test "flog menu" { run menu [ "${status}" -eq 0 ] } @test "flog reset" { - if ! "${BATS_TEST_DIRNAME}"/../dotbare log &>/dev/null; then - skip - fi run reset - [ "${status}" -eq 129 ] - [[ "${output}" =~ "usage: git reset [--mixed | --soft | --hard | --merge | --keep] [-q] []" ]] - [[ "${output}" =~ "flog_reset" ]] + [[ "${output}" =~ "reset --flog_reset" ]] } diff --git a/tests/fzf b/tests/fzf index 46aeb57..0681015 100755 --- a/tests/fzf +++ b/tests/fzf @@ -39,6 +39,9 @@ elif [[ "$*" =~ "--header=select tracked files to edit" ]]; then elif [[ "$*" =~ '--no-multi --header=select the target commit for HEAD' ]] && [[ "$*" =~ "show --color" ]]; then # dotbare freset --commit -y -- "./freset.bats" @test "freset select commit" echo "--freset_commit" +elif [[ "$*" =~ "--no-multi --header=commit --flog_reset" ]]; then + # dotbare flog -- "./flog.bats" @test "flog checkout routing" + echo "exit" elif [[ "$*" =~ '--header=select a commit' ]] && [[ "$*" =~ "show --color" ]]; then # dotbare flog --reset -y -- "./flog.bats" @test "flog reset" echo "--flog_reset" @@ -57,9 +60,6 @@ elif [[ "$*" =~ '--header=select stash to apply' ]] && [[ "$*" =~ "show -p __ -- elif [[ "$*" =~ "--header=select files to unstage" ]] && [[ "$*" =~ "diff HEAD --color=always" ]]; then # dotbare freset -- "./freset.bats" @test "freset select files" echo "-- freset_file" -elif [[ "$*" =~ "--no-multi --header=commit --flog_reset" ]]; then - # dotbare flog -- "./flog.bats" @test "flog checkout routing" - echo "exit" else echo "$@" fi