blob: 5bbfb591184d37dc6b6297a94380527d21b61cb4 (
about) (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#!/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]}" =~ "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]}" =~ "Unknown subcommand: bad-subcommand." ]]
[[ "${lines[1]}" = "Usage:" ]]
}
@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." ]]
[[ "${lines[1]}" = "Usage:" ]]
run ./website slides
[[ "$status" -eq 2 ]]
[[ "${lines[0]}" =~ "Missing required --name argument." ]]
[[ "${lines[1]}" = "Usage:" ]]
}
@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" ]]
[[ "${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:" ]]
}
|