diff options
author | EuAndreh <eu@euandre.org> | 2019-01-05 10:38:38 -0200 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2019-01-05 10:39:06 -0200 |
commit | 55e947d7901c17dbb1365a5cfb9f40acd50e903b (patch) | |
tree | 4e2a7db1001ccf64073824d907afaabf2e69ae91 /t | |
parent | Add BATS tests to CLI usage and basic interactions. (diff) | |
download | euandre.org-55e947d7901c17dbb1365a5cfb9f40acd50e903b.tar.gz euandre.org-55e947d7901c17dbb1365a5cfb9f40acd50e903b.tar.xz |
Print CLI errors using Term::ANSIColor.
Diffstat (limited to '')
-rwxr-xr-x | t/website.bats | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/t/website.bats b/t/website.bats index d10b39d..5bbfb59 100755 --- a/t/website.bats +++ b/t/website.bats @@ -9,15 +9,15 @@ cd "$BATS_TEST_DIRNAME/../" @test "Help: show short usage when no subcommand is given, exit code is 2" { run ./website [[ "$status" -eq 2 ]] - [[ "${lines[0]}" = "Usage:" ]] - [[ "${lines[-1]}" = "Missing subcommand." ]] + [[ "${lines[0]}" =~ "Missing subcommand." ]] + [[ "${lines[1]}" = "Usage:" ]] } @test "Help: show short usage for unknown subcommand, exit code is 2" { run ./website bad-subcommand [[ "$status" -eq 2 ]] - [[ "${lines[0]}" = "Usage:" ]] - [[ "${lines[-1]}" = "Unknown subcommand: bad-subcommand." ]] + [[ "${lines[0]}" =~ "Unknown subcommand: bad-subcommand." ]] + [[ "${lines[1]}" = "Usage:" ]] } @test "Help: show full toplevel help" { @@ -32,10 +32,12 @@ cd "$BATS_TEST_DIRNAME/../" @test "Help: show short subcommand usage when subcommand isn't invoked properly, exit code is 2" { run ./website pastebin [[ "$status" -eq 2 ]] - [[ "${lines[0]}" = "Missing required --title argument." ]] + [[ "${lines[0]}" =~ "Missing required --title argument." ]] + [[ "${lines[1]}" = "Usage:" ]] run ./website slides [[ "$status" -eq 2 ]] - [[ "${lines[0]}" = "Missing required --name argument." ]] + [[ "${lines[0]}" =~ "Missing required --name argument." ]] + [[ "${lines[1]}" = "Usage:" ]] } @test "Help: show subcommand manpage" { @@ -57,4 +59,12 @@ cd "$BATS_TEST_DIRNAME/../" run ./website pastebin --title [[ "$status" = 2 ]] [[ "${lines[0]}" = "Option title requires an argument" ]] + [[ "${lines[1]}" = "Usage:" ]] +} + +@test "Slides: required input for --name" { + run ./website slides --name + [[ "$status" = 2 ]] + [[ "${lines[0]}" = "Option name requires an argument" ]] + [[ "${lines[1]}" = "Usage:" ]] } |