forked from asdf-vm/asdf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelp_command.bats
81 lines (61 loc) · 1.58 KB
/
help_command.bats
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
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env bats
load test_helpers
setup() {
setup_asdf_dir
install_dummy_plugin
install_dummy_legacy_plugin
run asdf install dummy 1.0
run asdf install dummy 1.1
PROJECT_DIR="$HOME/project"
mkdir -p "$PROJECT_DIR"
}
teardown() {
clean_asdf_dir
}
@test "help should show dummy plugin help" {
cd "$PROJECT_DIR"
run asdf help "dummy"
expected_output="$(
cat <<EOF
Dummy plugin documentation
Dummy plugin is a plugin only used for unit tests
EOF
)"
[ "$status" -eq 0 ]
[ "$output" = "$expected_output" ]
}
@test "help should show dummy plugin help specific to version when version is present" {
cd "$PROJECT_DIR"
run asdf help "dummy" "1.2.3"
expected_output="$(
cat <<EOF
Dummy plugin documentation
Dummy plugin is a plugin only used for unit tests
Details specific for version 1.2.3
EOF
)"
[ "$status" -eq 0 ]
[ "$output" = "$expected_output" ]
}
@test "help should fail for unknown plugins" {
cd "$PROJECT_DIR"
run asdf help "sunny"
[ "$status" -eq 1 ]
[ "$output" = "No plugin named sunny" ]
}
@test "help should fail when plugin doesn't have documentation callback" {
cd "$PROJECT_DIR"
run asdf help "legacy-dummy"
[ "$status" -eq 1 ]
[ "$output" = "No documentation for plugin legacy-dummy" ]
}
@test "help should show asdf help when no plugin name is provided" {
cd "$PROJECT_DIR"
run asdf help
[ "$status" -eq 0 ]
[[ $output == 'version: v'* ]]
[[ $output == *$'MANAGE PLUGINS\n'* ]]
[[ $output == *$'MANAGE PACKAGES\n'* ]]
[[ $output == *$'UTILS\n'* ]]
[[ $output == *$'"Late but latest"\n-- Rajinikanth' ]]
}