Fix tldr test (#669)

This commit is contained in:
Denis Isidoro 2022-01-12 08:50:07 -03:00 committed by GitHub
parent a3a48419de
commit f3e237de4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View file

@ -46,7 +46,7 @@ test::_escape() {
test::equals() {
local -r actual="$(cat)"
local -r expected="$(echo "${1:-}")"
local -r expected="${1:-}"
local -r actual2="$(echo "$actual" | test::_escape)"
local -r expected2="$(echo "$expected" | test::_escape)"
@ -57,6 +57,19 @@ test::equals() {
fi
}
test::contains() {
local -r haystack="$(cat)"
local -r needle="${1:-}"
local -r haystack2="$(echo "$haystack" | test::_escape)"
local -r needle2="$(echo "$needle" | test::_escape)"
if [[ "$haystack2" != *"$needle2"* ]]; then
log::error "Expected '${haystack}' to include '${needle2}'"
return 2
fi
}
test::finish() {
echo
if [ $SKIPPED -gt 0 ]; then

View file

@ -53,12 +53,12 @@ _get_tests() {
_navi_tldr() {
_navi --tldr docker --query ps --print --best-match \
| test::equals "docker ps"
| test::contains "docker ps"
}
_navi_cheatsh() {
_navi --cheatsh docker --query remove --print --best-match \
| test::equals "docker rm container_name"
| test::contains "docker rm"
}
_navi_widget() {