-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathdefault_env.bats
More file actions
67 lines (49 loc) · 1.76 KB
/
default_env.bats
File metadata and controls
67 lines (49 loc) · 1.76 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
setup() {
load "${BATS_UTILS_PATH}/bats-support/load.bash"
load "${BATS_UTILS_PATH}/bats-assert/load.bash"
cd ./tests/default_env
TEST_DIR=$(pwd)
}
@test "LETS_COMMAND_NAME: contains command name" {
run lets print-command-name-from-env
assert_success
assert_line --index 0 "print-command-name-from-env"
}
@test "LETS_COMMAND_ARGS: contains all positional args" {
run lets print-command-args-from-env --foo --bar=x y
assert_success
assert_line --index 0 "--foo --bar=x y"
}
@test "\$@: contains all positional args" {
run lets print-shell-args --foo --bar=x y
assert_success
assert_line --index 0 "--foo --bar=x y"
}
@test "LETS_CONFIG: contains config filename" {
run lets print-env LETS_CONFIG
assert_success
assert_line --index 0 "LETS_CONFIG=lets.yaml"
}
@test "LETS_CONFIG_DIR: contains config dir" {
run lets print-env LETS_CONFIG_DIR
assert_success
assert_line --index 0 "LETS_CONFIG_DIR=${TEST_DIR}"
}
@test "LETS_CONFIG_DIR: specified, overrides config dir" {
LETS_CONFIG_DIR=./a run lets print-env LETS_CONFIG_DIR
assert_success
assert_line --index 0 "LETS_CONFIG_DIR=${TEST_DIR}/a"
}
@test "LETS_COMMAND_WORK_DIR: contains work_dir path if specified for command (in dir with lets config)" {
cd ./a
run lets print-workdir
assert_success
assert_line --index 0 "LETS_COMMAND_WORK_DIR=${TEST_DIR}/a/b"
}
@test "LETS_COMMAND_WORK_DIR: fail if LETS_CONFIG_DIR specified and no work_dir exists in LETS_CONFIG_DIR path" {
LETS_CONFIG_DIR=./a run lets print-workdir
assert_failure
assert_line --index 0 --partial "lets: print-workdir"
assert_line --index 0 --partial "failed here"
assert_line --index 1 "lets: chdir ${TEST_DIR}/b: no such file or directory"
}