mirror of
https://github.com/dolthub/dolt.git
synced 2026-05-12 19:39:32 -05:00
Used bats/expect to perform a better test
This commit is contained in:
@@ -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 ]
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
spawn -noecho dolt log --oneline
|
||||
expect eof
|
||||
Reference in New Issue
Block a user