aboutsummaryrefslogtreecommitdiff
path: root/spec/cli/cli_test_helper.sh
diff options
context:
space:
mode:
Diffstat (limited to 'spec/cli/cli_test_helper.sh')
-rwxr-xr-xspec/cli/cli_test_helper.sh27
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/cli/cli_test_helper.sh b/spec/cli/cli_test_helper.sh
index ade1546..0f46969 100755
--- a/spec/cli/cli_test_helper.sh
+++ b/spec/cli/cli_test_helper.sh
@@ -123,6 +123,33 @@ assert_output_equals() {
123 fi 123 fi
124} 124}
125 125
126# Assert that output does NOT contain expected string
127assert_output_not_contains() {
128 local description="$1"
129 local unexpected="$2"
130 shift 2
131 TESTS_RUN=$((TESTS_RUN + 1))
132
133 if "$@" > /tmp/test_stdout.txt 2> /tmp/test_stderr.txt; then
134 if grep -qF -- "$unexpected" /tmp/test_stdout.txt || grep -qF -- "$unexpected" /tmp/test_stderr.txt; then
135 echo -e "${RED}✗${NC} $description (output contains '$unexpected')"
136 echo -e " ${YELLOW}STDOUT:$(cat /tmp/test_stdout.txt)${NC}"
137 echo -e " ${YELLOW}STDERR:$(cat /tmp/test_stderr.txt)${NC}"
138 TESTS_FAILED=$((TESTS_FAILED + 1))
139 return 1
140 else
141 echo -e "${GREEN}✓${NC} $description"
142 TESTS_PASSED=$((TESTS_PASSED + 1))
143 return 0
144 fi
145 else
146 echo -e "${RED}✗${NC} $description (command failed)"
147 echo -e " ${YELLOW}Exit code: $?${NC}"
148 TESTS_FAILED=$((TESTS_FAILED + 1))
149 return 1
150 fi
151}
152
126# Assert file exists 153# Assert file exists
127assert_file_exists() { 154assert_file_exists() {
128 local description="$1" 155 local description="$1"