Add integration tests for pager handling

This commit is contained in:
sharkdp 2018-10-17 20:44:15 +02:00 committed by David Peter
parent bb1f5aa841
commit 2c7087b8de
1 changed files with 37 additions and 0 deletions

View File

@ -7,6 +7,8 @@ fn bat() -> Command {
let mut cmd = Command::main_binary().unwrap();
cmd.current_dir("tests/examples");
cmd.arg("--no-config");
cmd.env_remove("PAGER");
cmd.env_remove("BAT_PAGER");
cmd
}
@ -113,3 +115,38 @@ fn do_not_exit_directory() {
.stdout("hello world\n")
.failure();
}
#[test]
fn pager_basic() {
bat()
.env("PAGER", "echo pager-output")
.arg("--paging=always")
.arg("test.txt")
.assert()
.success()
.stdout("pager-output\n");
}
#[test]
fn pager_overwrite() {
bat()
.env("PAGER", "echo other-pager")
.env("BAT_PAGER", "echo pager-output")
.arg("--paging=always")
.arg("test.txt")
.assert()
.success()
.stdout("pager-output\n");
}
#[test]
fn pager_disable() {
bat()
.env("PAGER", "echo other-pager")
.env("BAT_PAGER", "")
.arg("--paging=always")
.arg("test.txt")
.assert()
.success()
.stdout("hello world\n");
}