forked from asdf-vm/asdf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcurrent_command.bats
More file actions
73 lines (56 loc) · 1.87 KB
/
Copy pathcurrent_command.bats
File metadata and controls
73 lines (56 loc) · 1.87 KB
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
#!/usr/bin/env bats
load test_helpers
. $(dirname $BATS_TEST_DIRNAME)/lib/commands/plugin-list.sh
. $(dirname $BATS_TEST_DIRNAME)/lib/commands/current.sh
setup() {
setup_asdf_dir
install_dummy_plugin
PROJECT_DIR=$HOME/project
OTHER_DIR=$HOME/other
mkdir -p $ASDF_DIR/installs/dummy/1.0.0 $ASDF_DIR/installs/dummy/1.1.0 $PROJECT_DIR $OTHER_DIR
mkdir -p $ASDF_DIR/installs/other/1.0.0 $ASDF_DIR/plugins/other
echo 'dummy 1.0.0' >> $HOME/.tool-versions
echo 'other 1.0.0' >> $HOME/.tool-versions
echo 'dummy 1.1.0' >> $PROJECT_DIR/.tool-versions
echo '1.2.0' >> $OTHER_DIR/.dummy-version
}
teardown() {
clean_asdf_dir
}
@test "current without arguments should print all versions" {
cd $PROJECT_DIR
run current_command
expected=$(echo -e "dummy 1.1.0 (set by $PROJECT_DIR/.tool-versions)\nother 1.0.0 (set by $HOME/.tool-versions)")
[ "$status" -eq 0 ]
[ "$output" = "$expected" ]
}
@test "current should derive from the local .tool_versions when it exists" {
cd $PROJECT_DIR
run current_command "dummy"
[ "$status" -eq 0 ]
[ "$output" = "dummy 1.1.0 (set by $PROJECT_DIR/.tool-versions)" ]
}
@test "current should derive from the global .tool_versions when local doesn't exist" {
cd $OTHER_DIR
run current_command "dummy"
[ "$status" -eq 0 ]
[ "$output" = "dummy 1.0.0 (set by $HOME/.tool-versions)" ]
}
@test "current should derive from the legacy file if enabled and hide the file path" {
echo 'legacy_version_file = yes' > $HOME/.asdfrc
cd $OTHER_DIR
run current_command "dummy"
[ "$status" -eq 0 ]
[ "$output" = "dummy 1.2.0" ]
}
@test "current should error when the plugin doesn't exist" {
run current_command "foobar"
[ "$status" -eq 1 ]
}
@test "current should error when no version is set" {
cd $OTHER_DIR
rm $HOME/.tool-versions
run current_command "dummy"
[ "$status" -eq 1 ]
[ "$output" = "No version set for dummy" ]
}