aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xt/website.bats60
1 files changed, 60 insertions, 0 deletions
diff --git a/t/website.bats b/t/website.bats
new file mode 100755
index 0000000..d10b39d
--- /dev/null
+++ b/t/website.bats
@@ -0,0 +1,60 @@
+#!/usr/bin/env bats
+
+# Go to the directory where ./website is.
+cd "$BATS_TEST_DIRNAME/../"
+
+# exit code 1: error running command
+# exit code 2: couldn't parse the command line argument
+
+@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." ]]
+}
+
+@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." ]]
+}
+
+@test "Help: show full toplevel help" {
+ run ./website --help
+ [[ "$status" -eq 0 ]]
+ [[ "${lines[0]}" = "NAME" ]]
+ run ./website -h
+ [[ "$status" -eq 0 ]]
+ [[ "${lines[0]}" = "NAME" ]]
+}
+
+@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." ]]
+ run ./website slides
+ [[ "$status" -eq 2 ]]
+ [[ "${lines[0]}" = "Missing required --name argument." ]]
+}
+
+@test "Help: show subcommand manpage" {
+ run ./website pastebin -h
+ [[ "$status" -eq 0 ]]
+ [[ "${lines[0]}" = "NAME" ]]
+ run ./website pastebin --help
+ [[ "$status" -eq 0 ]]
+ [[ "${lines[0]}" = "NAME" ]]
+ run ./website slides -h
+ [[ "$status" -eq 0 ]]
+ [[ "${lines[0]}" = "NAME" ]]
+ run ./website slides --help
+ [[ "$status" -eq 0 ]]
+ [[ "${lines[0]}" = "NAME" ]]
+}
+
+@test "Pastebin: required input for --title" {
+ run ./website pastebin --title
+ [[ "$status" = 2 ]]
+ [[ "${lines[0]}" = "Option title requires an argument" ]]
+}