forked from asdf-vm/asdf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreshim_command.bats
69 lines (53 loc) · 1.55 KB
/
reshim_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
#!/usr/bin/env bats
load test_helpers
. $(dirname $BATS_TEST_DIRNAME)/lib/commands/reshim.sh
. $(dirname $BATS_TEST_DIRNAME)/lib/commands/install.sh
setup() {
setup_asdf_dir
install_dummy_plugin
PROJECT_DIR=$HOME/project
mkdir $PROJECT_DIR
}
teardown() {
clean_asdf_dir
}
@test "reshim command should remove shims of removed binaries" {
run install_command dummy 1.0
[ "$status" -eq 0 ]
[ -f "$ASDF_DIR/shims/dummy" ]
run reshim_command dummy
[ "$status" -eq 0 ]
[ -f "$ASDF_DIR/shims/dummy" ]
run rm "$ASDF_DIR/installs/dummy/1.0/bin/dummy"
run reshim_command dummy
[ "$status" -eq 0 ]
[ ! -f "$ASDF_DIR/shims/dummy" ]
}
@test "reshim should remove metadata of removed binaries" {
run install_command dummy 1.0
run install_command dummy 1.1
run rm "$ASDF_DIR/installs/dummy/1.0/bin/dummy"
run reshim_command dummy
[ "$status" -eq 0 ]
[ -f "$ASDF_DIR/shims/dummy" ]
run grep "asdf-plugin-version: 1.0" "$ASDF_DIR/shims/dummy"
[ "$status" -eq 1 ]
run grep "asdf-plugin-version: 1.1" "$ASDF_DIR/shims/dummy"
[ "$status" -eq 0 ]
}
@test "reshim should not duplicate shims" {
cd $PROJECT_DIR
run install_command dummy 1.0
run install_command dummy 1.1
[ "$status" -eq 0 ]
[ -f "$ASDF_DIR/shims/dummy" ]
run rm $ASDF_DIR/shims/*
[ "$status" -eq 0 ]
[ "0" -eq "$(ls $ASDF_DIR/shims/dummy* | wc -l)" ]
run reshim_command dummy
[ "$status" -eq 0 ]
[ "1" -eq "$(ls $ASDF_DIR/shims/dummy* | wc -l)" ]
run reshim_command dummy
[ "$status" -eq 0 ]
[ "1" -eq "$(ls $ASDF_DIR/shims/dummy* | wc -l)" ]
}