forked from asdf-vm/asdf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist_command.bats
111 lines (94 loc) · 3.08 KB
/
list_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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/env bats
load test_helpers
setup() {
setup_asdf_dir
install_dummy_plugin
install_dummy_broken_plugin
PROJECT_DIR="$HOME/project"
mkdir -p "$PROJECT_DIR"
}
teardown() {
clean_asdf_dir
}
@test "list_command should list plugins with installed versions" {
run asdf install dummy 1.0.0
run asdf install dummy 1.1.0
run asdf list
[[ "$output" == *$'dummy\n 1.0.0\n 1.1.0'* ]]
[[ "$output" == *$'dummy-broken\n No versions installed'* ]]
[ "$status" -eq 0 ]
}
@test "list_command should list plugins with installed versions and any selected versions marked with asterisk" {
cd "$PROJECT_DIR"
echo 'dummy 1.1.0' >>"$PROJECT_DIR/.tool-versions"
run asdf install dummy 1.0.0
run asdf install dummy 1.1.0
run asdf list
[[ "$output" == *$'dummy\n 1.0.0\n *1.1.0'* ]]
[[ "$output" == *$'dummy-broken\n No versions installed'* ]]
[ "$status" -eq 0 ]
}
@test "list_command should continue listing even when no version is installed for any of the plugins" {
run install_mock_plugin "dummy"
run install_mock_plugin "mummy"
run install_mock_plugin "tummy"
run asdf install dummy 1.0.0
run asdf install tummy 2.0.0
run asdf list
[[ "$output" == *$'dummy\n 1.0.0'* ]]
[[ "$output" == *$'dummy-broken\n No versions installed'* ]]
[[ "$output" == *$'mummy\n No versions installed'* ]]
[[ "$output" == *$'tummy\n 2.0.0'* ]]
[ "$status" -eq 0 ]
}
@test "list_command with plugin should list installed versions" {
run asdf install dummy 1.0.0
run asdf install dummy 1.1.0
run asdf list dummy
[ $' 1.0.0\n 1.1.0' = "$output" ]
[ "$status" -eq 0 ]
}
@test "list_command with version filters installed versions" {
run asdf install dummy 1.0
run asdf install dummy 1.1
run asdf install dummy 2.0
run asdf list dummy 1
[ $' 1.0\n 1.1' = "$output" ]
[ "$status" -eq 0 ]
}
@test "list_command with an invalid version should return an error" {
run asdf install dummy 1.0
run asdf install dummy 1.1
run asdf list dummy 2
[ "No compatible versions installed (dummy 2)" = "$output" ]
[ "$status" -eq 1 ]
}
@test "list_all_command lists available versions" {
run asdf list-all dummy
[ $'1.0.0\n1.1.0\n2.0.0' = "$output" ]
[ "$status" -eq 0 ]
}
@test "list_all_command with version filters available versions" {
run asdf list-all dummy 1
[ $'1.0.0\n1.1.0' = "$output" ]
[ "$status" -eq 0 ]
}
@test "list_all_command with an invalid version should return an error" {
run asdf list-all dummy 3
[ "No compatible versions available (dummy 3)" = "$output" ]
[ "$status" -eq 1 ]
}
@test "list_all_command fails when list-all script exits with non-zero code" {
run asdf list-all dummy-broken
[ "$status" -eq 1 ]
[[ "$output" == "Plugin dummy-broken's list-all callback script failed with output:"* ]]
}
@test "list_all_command displays stderr then stdout when failing" {
run asdf list-all dummy-broken
[[ "$output" == *"List-all failed!"* ]]
[[ "$output" == *"Attempting to list versions" ]]
}
@test "list_all_command ignores stderr when completing successfully" {
run asdf list-all dummy
[[ "$output" != *"ignore this error"* ]]
}