-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolored-logger.bats
More file actions
executable file
·62 lines (50 loc) · 1.63 KB
/
colored-logger.bats
File metadata and controls
executable file
·62 lines (50 loc) · 1.63 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
#!/usr/bin/env bats
load 'colored-logger'
levelKeywords=(debug info warn error)
@test 'colored-logger warns without arguments' {
run colored-logger
(( status == 0 ))
(( ${#lines[@]} == 1 ))
grep '^colored-logger: expecting at least one argument$' <<< "$output"
}
@test 'colored-logger warns when single argument is a level-keyword' {
for level in "${levelKeywords[@]}"; do
run colored-logger "$level"
(( status == 0 ))
(( ${#lines[@]} == 1 ))
grep '^colored-logger: expecting a message$' <<< "${lines[0]}"
done
}
@test 'colored-logger writes a message to stdout for non-debug messages' {
for level in "${levelKeywords[@]}"; do
[[ $level = 'debug' ]] && continue
run colored-logger "$level" 'For the love of House'
(( status == 0 ))
grep 'For the love of House' <<< "${lines[0]}"
done
}
@test 'colored-logger debug is default level and is silent by default' {
run colored-logger 'I Chase Rivers'
(( status == 0 ))
[[ -z $output ]]
run colored-logger debug 'I Chase Rivers'
[[ -z $output ]]
}
@test 'colored-logger debug outputs when VERBOSE is true' {
# shellcheck disable=SC2034
VERBOSE=true
run colored-logger 'I Chase Rivers'
(( status == 0 ))
[[ $output =~ 'I Chase Rivers' ]]
run colored-logger debug 'I Chase Rivers'
[[ $output =~ 'I Chase Rivers' ]]
}
@test 'colored-logger handles barewords' {
for level in "${levelKeywords[@]}"; do
# shellcheck disable=SC2034
VERBOSE=true
run colored-logger "$level" Something Good Can Work Remix
(( status == 0 ))
[[ $output =~ 'Something Good Can Work Remix' ]]
done
}