Created
June 24, 2020 07:03
-
-
Save XIIIVI/1806d2d20a388704c124713f1e6af9c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# check_if_file_contains_string | |
# - param1: file containing the text | |
# - param2: string to find | |
# - param3: message for success | |
# - param4: message for failure | |
# | |
check_if_file_contains_string() { | |
local TARGET_FILE="${1}" | |
local STRING_TO_FIND="${2}" | |
local MESSAGE_FOR_SUCCESS="${3}" | |
local MESSAGE_FOR_FAILURE="${4}" | |
TEST_COUNT=$((TEST_COUNT + 1)) | |
if grep -q "${STRING_TO_FIND}" "${TARGET_FILE}"; | |
then | |
test_succeeded "${MESSAGE_FOR_SUCCESS}" | |
else | |
test_failed "${MESSAGE_FOR_FAILURE}" | |
display_file_content "${TARGET_FILE}" | |
fi | |
} | |
# | |
# check_if_file_does_not_contain_string | |
# - param1: file containing the text | |
# - param2: string to find | |
# - param3: message for success | |
# - param4: message for failure | |
# | |
check_if_file_does_not_contain_string() { | |
local TARGET_FILE="${1}" | |
local STRING_TO_FIND="${2}" | |
local MESSAGE_FOR_SUCCESS="${3}" | |
local MESSAGE_FOR_FAILURE="${4}" | |
TEST_COUNT=$((TEST_COUNT + 1)) | |
if grep -q "${STRING_TO_FIND}" "${TARGET_FILE}"; | |
then | |
test_failed "${MESSAGE_FOR_FAILURE}" | |
display_file_content "${TARGET_FILE}" | |
else | |
test_succeeded "${MESSAGE_FOR_SUCCESS}" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment