-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.bats
More file actions
97 lines (83 loc) · 2.24 KB
/
script.bats
File metadata and controls
97 lines (83 loc) · 2.24 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# shellcheck disable=SC2154
setup_file() {
source test/common/setup-file.sh
_common_setup_file
# export BATS_NO_PARALLELIZE_WITHIN_FILE=true
export DRY_RUN=true
}
setup() {
source test/common/setup.sh
_common_setup
source test/common/helper.sh
}
# bats file_tags=script
# bats test_tags=bootstrap,type:unit
@test "script/bootstrap" {
local chezmoi_args=(
"--dry-run"
"--refresh-externals=never"
)
export CI=true
run_script ./script/bootstrap "${chezmoi_args[@]}"
refute_output --regexp "Tip:"
assert_stderr_line "DRY-RUN: Running 'chezmoi init --apply --source=$PWD ${chezmoi_args[*]}'"
assert_success
}
# bats test_tags=startup,type:unit
@test "script/startup" {
check_command time
export BENCH_ITERATIONS=1
export SHELL=dummy
export TMPDIR="$BATS_TEST_TMPDIR"
stub_seq dummy $((BENCH_ITERATIONS + 2))
run_script ./script/startup
unstub dummy 2>/dev/null || true
assert_stderr_line --regexp "startup 1/$BENCH_ITERATIONS: dummy -ci exit"
assert_success
jq . <<<"$output" >/dev/null
}
# bats test_tags=check,type:unit
# @test "script/check" {
# stub_seq goss 1
# stub_seq mise 1
# stub_seq nvim 1
# run_script ./script/check
# unstub goss 2>/dev/null || true
# unstub mise 2>/dev/null || true
# unstub nvim 2>/dev/null || true
#
# if has_feature goss; then
# assert_stderr_line "Checking goss"
# fi
# if has_feature mise; then
# assert_stderr_line "Checking mise"
# fi
# if has_feature neovim; then
# assert_stderr_line "Checking nvim"
# fi
# assert_success
# }
# bats test_tags=install,type:unit
@test "install-password-manager: skips on unknown command" {
# shellcheck disable=SC2030,SC2031
export CHEZMOI_COMMAND=test
# shellcheck disable=SC2030,SC2031
export CHEZMOI_WORKING_TREE="$PWD"
run_script home/.install-password-manager.sh
refute_output
refute_stderr
assert_success
}
# bats test_tags=install,type:unit
@test "install-password-manager: exits if already installed" {
stub bws "true"
# shellcheck disable=SC2030,SC2031
export CHEZMOI_COMMAND=apply
# shellcheck disable=SC2030,SC2031
export CHEZMOI_WORKING_TREE="$PWD"
run_script home/.install-password-manager.sh
unstub bws 2>/dev/null || true
refute_output
refute_stderr
assert_success
}