Skip to content

Commit

Permalink
fix(tests): 🚨 fix shellcheck warning caused by functions with the sam…
Browse files Browse the repository at this point in the history
…e name

Add suffixes to double-color-cecho internal functions.
  • Loading branch information
landure committed Dec 7, 2023
1 parent 70ca55d commit 487b916
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions test/cecho.bats
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,10 @@ teardown() {
}

@test "Check tput behaviour is similar to echo for multiple arguments" {
run cecho --force 'ERROR' "input" "with" "random" "spacing"
run cecho --force 'ERROR' "input" "with" "random" "spacing"
assert_success
# shellcheck disable=SC2291
assert_output "$(tput 'setaf' 1 || true)$(tput 'bold' || true)$(echo -n "input" "with" "random" "spacing")$(tput 'sgr0' || true)"
assert_output "$(tput 'setaf' 1 || true)$(tput 'bold' || true)$(echo -n "input" "with" "random" "spacing")$(tput 'sgr0' || true)"
}

@test "output two lines" {
Expand All @@ -258,22 +258,22 @@ teardown() {
}

@test "Check output line break at end of output." {
function double-color-cecho() {
function double-color-cecho-line-break() {
cecho --force 'red' "output"
cecho --force 'green' "second line"
}
run double-color-cecho
run double-color-cecho-line-break
assert_success
assert_line --index 0 "$(tput 'setaf' 1 || true)output$(tput 'sgr0' || true)"
assert_line --index 1 "$(tput 'setaf' 2 || true)second line$(tput 'sgr0' || true)"
}

@test "Check -n functionnality." {
function double-color-cecho() {
function double-color-cecho-functionnality() {
cecho --force -n 'red' "output"
cecho --force 'green' "first line"
}
run double-color-cecho
run double-color-cecho-functionnality
assert_success
assert_line --index 0 "$(tput 'setaf' 1 || true)output$(tput 'sgr0' || true)$(tput 'setaf' 2 || true)first line$(tput 'sgr0' || true)"
}
Expand Down

0 comments on commit 487b916

Please sign in to comment.