diff --git a/integration-tests/bats/pager.bats b/integration-tests/bats/pager.bats new file mode 100644 index 0000000000..4f8c778232 --- /dev/null +++ b/integration-tests/bats/pager.bats @@ -0,0 +1,36 @@ +#!/usr/bin/env bats +load $BATS_TEST_DIRNAME/helper/common.bash + +setup() { + setup_common + + for i in {1..20}; do + dolt commit --allow-empty -m "commit $i abc" + done +} + +teardown() { + teardown_common +} + +export NO_COLOR=1 + +@test "dolt log with pager" { + # We use `expect` because we need TTY simulation to get the pager to kick in + export DOLT_PAGER="tail -n 2" + run expect $BATS_TEST_DIRNAME/pager.expect + [ "$status" -eq 0 ] + [[ ! "$output" =~ "commit 2 abc" ]] || false + [[ "$output" =~ "commit 1 abc" ]] || false + [[ "$output" =~ "Initialize data repository" ]] || false + [ "${#lines[@]}" -eq 2 ] + + export DOLT_PAGER="head -n 3" + run expect $BATS_TEST_DIRNAME/pager.expect + [ "$status" -eq 0 ] + [[ "$output" =~ "commit 20 abc" ]] || false + [[ "$output" =~ "commit 19 abc" ]] || false + [[ "$output" =~ "commit 18 abc" ]] || false + [[ ! "$output" =~ "commit 17 abc" ]] || false + [ "${#lines[@]}" -eq 3 ] +} \ No newline at end of file diff --git a/integration-tests/bats/pager.expect b/integration-tests/bats/pager.expect new file mode 100644 index 0000000000..042c3515e1 --- /dev/null +++ b/integration-tests/bats/pager.expect @@ -0,0 +1,4 @@ +#!/usr/bin/expect + +spawn -noecho dolt log --oneline +expect eof