test-mail.sh 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  1. #!/bin/bash
  2. # test-mail.sh - Test harness for mail-ops
  3. # Outputs: number of passing test cases
  4. # Each test prints PASS/FAIL and we count PASSes at the end
  5. set -uo pipefail
  6. MAIL_DB="$HOME/.claude/mail.db"
  7. MAIL_SCRIPT="$(dirname "$0")/mail-db.sh"
  8. HOOK_SCRIPT="$(dirname "$0")/../../hooks/check-mail.sh"
  9. # Resolve relative to repo root if needed
  10. if [ ! -f "$HOOK_SCRIPT" ]; then
  11. HOOK_SCRIPT="$(cd "$(dirname "$0")/../../.." && pwd)/hooks/check-mail.sh"
  12. fi
  13. PASS=0
  14. FAIL=0
  15. TOTAL=0
  16. assert() {
  17. local name="$1"
  18. local expected="$2"
  19. local actual="$3"
  20. TOTAL=$((TOTAL + 1))
  21. if [ "$expected" = "$actual" ]; then
  22. echo "PASS: $name"
  23. PASS=$((PASS + 1))
  24. else
  25. echo "FAIL: $name (expected='$expected', actual='$actual')"
  26. FAIL=$((FAIL + 1))
  27. fi
  28. }
  29. assert_contains() {
  30. local name="$1"
  31. local needle="$2"
  32. local haystack="$3"
  33. TOTAL=$((TOTAL + 1))
  34. if echo "$haystack" | grep -qF "$needle"; then
  35. echo "PASS: $name"
  36. PASS=$((PASS + 1))
  37. else
  38. echo "FAIL: $name (expected to contain '$needle')"
  39. FAIL=$((FAIL + 1))
  40. fi
  41. }
  42. assert_not_empty() {
  43. local name="$1"
  44. local value="$2"
  45. TOTAL=$((TOTAL + 1))
  46. if [ -n "$value" ]; then
  47. echo "PASS: $name"
  48. PASS=$((PASS + 1))
  49. else
  50. echo "FAIL: $name (was empty)"
  51. FAIL=$((FAIL + 1))
  52. fi
  53. }
  54. assert_empty() {
  55. local name="$1"
  56. local value="$2"
  57. TOTAL=$((TOTAL + 1))
  58. if [ -z "$value" ]; then
  59. echo "PASS: $name"
  60. PASS=$((PASS + 1))
  61. else
  62. echo "FAIL: $name (expected empty, got '$value')"
  63. FAIL=$((FAIL + 1))
  64. fi
  65. }
  66. assert_exit_code() {
  67. local name="$1"
  68. local expected="$2"
  69. local actual="$3"
  70. TOTAL=$((TOTAL + 1))
  71. if [ "$expected" = "$actual" ]; then
  72. echo "PASS: $name"
  73. PASS=$((PASS + 1))
  74. else
  75. echo "FAIL: $name (exit code expected=$expected, actual=$actual)"
  76. FAIL=$((FAIL + 1))
  77. fi
  78. }
  79. # --- Setup: clean slate ---
  80. rm -f "$MAIL_DB"
  81. echo "=== Basic Operations ==="
  82. # T1: Init creates database
  83. bash "$MAIL_SCRIPT" init >/dev/null 2>&1
  84. assert "init creates database" "true" "$([ -f "$MAIL_DB" ] && echo true || echo false)"
  85. # T2: Count on empty inbox
  86. result=$(bash "$MAIL_SCRIPT" count)
  87. assert "empty inbox count is 0" "0" "$result"
  88. # T3: Send a message
  89. result=$(bash "$MAIL_SCRIPT" send "test-project" "Hello" "World" 2>&1)
  90. assert_contains "send succeeds" "Sent to test-project" "$result"
  91. # T4: Count after send (we're in claude-mods, sent to test-project)
  92. result=$(bash "$MAIL_SCRIPT" count)
  93. assert "count still 0 for sender project" "0" "$result"
  94. # T5: Send to self
  95. result=$(bash "$MAIL_SCRIPT" send "claude-mods" "Self mail" "Testing self-send" 2>&1)
  96. assert_contains "self-send succeeds" "Sent to claude-mods" "$result"
  97. # T6: Count after self-send
  98. result=$(bash "$MAIL_SCRIPT" count)
  99. assert "count is 1 after self-send" "1" "$result"
  100. # T7: Unread shows message
  101. result=$(bash "$MAIL_SCRIPT" unread)
  102. assert_contains "unread shows subject" "Self mail" "$result"
  103. # T8: Read marks as read
  104. bash "$MAIL_SCRIPT" read >/dev/null 2>&1
  105. result=$(bash "$MAIL_SCRIPT" count)
  106. assert "count is 0 after read" "0" "$result"
  107. # T9: List shows read messages
  108. result=$(bash "$MAIL_SCRIPT" list)
  109. assert_contains "list shows read status" "read" "$result"
  110. # T10: Projects lists known projects
  111. result=$(bash "$MAIL_SCRIPT" projects)
  112. assert_contains "projects lists claude-mods" "claude-mods" "$result"
  113. assert_contains "projects lists test-project" "test-project" "$result"
  114. echo ""
  115. echo "=== Edge Cases ==="
  116. # T11: Empty body - should fail gracefully
  117. result=$(bash "$MAIL_SCRIPT" send "target" "subject" "" 2>&1)
  118. exit_code=$?
  119. # Empty body should either fail or send empty - document the behavior
  120. TOTAL=$((TOTAL + 1))
  121. if [ $exit_code -ne 0 ] || echo "$result" | grep -qiE "error|required|empty"; then
  122. echo "PASS: empty body rejected or warned"
  123. PASS=$((PASS + 1))
  124. else
  125. echo "FAIL: empty body accepted silently"
  126. FAIL=$((FAIL + 1))
  127. fi
  128. # T12: Missing arguments to send
  129. result=$(bash "$MAIL_SCRIPT" send 2>&1)
  130. exit_code=$?
  131. assert_exit_code "send with no args fails" "1" "$exit_code"
  132. # T13: SQL injection in subject
  133. bash "$MAIL_SCRIPT" send "claude-mods" "'; DROP TABLE messages; --" "injection test" >/dev/null 2>&1
  134. result=$(bash "$MAIL_SCRIPT" count)
  135. # If table still exists and count works, injection failed (good)
  136. TOTAL=$((TOTAL + 1))
  137. if [ -n "$result" ] && [ "$result" -ge 0 ] 2>/dev/null; then
  138. echo "PASS: SQL injection in subject blocked"
  139. PASS=$((PASS + 1))
  140. else
  141. echo "FAIL: SQL injection may have succeeded"
  142. FAIL=$((FAIL + 1))
  143. fi
  144. # T14: SQL injection in body
  145. bash "$MAIL_SCRIPT" send "claude-mods" "test" "'); DELETE FROM messages; --" >/dev/null 2>&1
  146. result=$(bash "$MAIL_SCRIPT" count)
  147. TOTAL=$((TOTAL + 1))
  148. if [ -n "$result" ] && [ "$result" -ge 0 ] 2>/dev/null; then
  149. echo "PASS: SQL injection in body blocked"
  150. PASS=$((PASS + 1))
  151. else
  152. echo "FAIL: SQL injection in body may have succeeded"
  153. FAIL=$((FAIL + 1))
  154. fi
  155. # T15: SQL injection in project name
  156. bash "$MAIL_SCRIPT" send "'; DROP TABLE messages; --" "test" "injection via project" >/dev/null 2>&1
  157. result=$(bash "$MAIL_SCRIPT" count)
  158. TOTAL=$((TOTAL + 1))
  159. if [ -n "$result" ] && [ "$result" -ge 0 ] 2>/dev/null; then
  160. echo "PASS: SQL injection in project name blocked"
  161. PASS=$((PASS + 1))
  162. else
  163. echo "FAIL: SQL injection in project name may have succeeded"
  164. FAIL=$((FAIL + 1))
  165. fi
  166. # T16: Special characters in body (newlines, quotes, backslashes)
  167. bash "$MAIL_SCRIPT" send "claude-mods" "special chars" 'Line1\nLine2 "quoted" and back\\slash' >/dev/null 2>&1
  168. result=$(bash "$MAIL_SCRIPT" read 2>&1)
  169. assert_contains "special chars preserved" "special chars" "$result"
  170. # T17: Very long message body (1000+ chars)
  171. long_body=$(python3 -c "print('x' * 2000)" 2>/dev/null || printf '%0.s.' $(seq 1 2000))
  172. bash "$MAIL_SCRIPT" send "claude-mods" "long msg" "$long_body" >/dev/null 2>&1
  173. result=$(bash "$MAIL_SCRIPT" count)
  174. assert "long message accepted" "1" "$result"
  175. bash "$MAIL_SCRIPT" read >/dev/null 2>&1
  176. # T18: Unicode in subject and body
  177. bash "$MAIL_SCRIPT" send "claude-mods" "Unicode test" "Hello from Tokyo" >/dev/null 2>&1
  178. result=$(bash "$MAIL_SCRIPT" read 2>&1)
  179. assert_contains "unicode in body" "Tokyo" "$result"
  180. # T19: Read by specific ID
  181. bash "$MAIL_SCRIPT" send "claude-mods" "ID test" "Read me by ID" >/dev/null 2>&1
  182. msg_id=$(sqlite3 "$MAIL_DB" "SELECT id FROM messages WHERE subject='ID test' AND read=0 LIMIT 1;")
  183. result=$(bash "$MAIL_SCRIPT" read "$msg_id" 2>&1)
  184. assert_contains "read by ID works" "Read me by ID" "$result"
  185. # T20: Read by invalid ID
  186. result=$(bash "$MAIL_SCRIPT" read 99999 2>&1)
  187. assert_empty "read invalid ID returns nothing" "$result"
  188. echo ""
  189. echo "=== Hook Tests ==="
  190. # T21: Hook silent on empty inbox
  191. bash "$MAIL_SCRIPT" read >/dev/null 2>&1 # clear any unread
  192. result=$(bash "$HOOK_SCRIPT" 2>&1)
  193. assert_empty "hook silent when no mail" "$result"
  194. # T22: Hook shows notification
  195. bash "$MAIL_SCRIPT" send "claude-mods" "Hook test" "Should trigger hook" >/dev/null 2>&1
  196. result=$(bash "$HOOK_SCRIPT" 2>&1)
  197. assert_contains "hook shows MAIL notification" "MAIL" "$result"
  198. assert_contains "hook shows message count" "1 unread" "$result"
  199. # T23: Hook with missing database
  200. backup_db="${MAIL_DB}.testbak"
  201. mv "$MAIL_DB" "$backup_db"
  202. result=$(bash "$HOOK_SCRIPT" 2>&1)
  203. exit_code=$?
  204. assert_exit_code "hook exits 0 with missing db" "0" "$exit_code"
  205. assert_empty "hook silent with missing db" "$result"
  206. mv "$backup_db" "$MAIL_DB"
  207. echo ""
  208. echo "=== Cleanup ==="
  209. # T24: Clear old messages
  210. bash "$MAIL_SCRIPT" read >/dev/null 2>&1 # mark all as read
  211. result=$(bash "$MAIL_SCRIPT" clear 0 2>&1)
  212. assert_contains "clear reports deleted count" "Cleared" "$result"
  213. # T25: Count after clear
  214. result=$(bash "$MAIL_SCRIPT" count)
  215. assert "count 0 after clear" "0" "$result"
  216. # T26: Help command
  217. result=$(bash "$MAIL_SCRIPT" help 2>&1)
  218. assert_contains "help shows usage" "Usage" "$result"
  219. # T27: Unknown command
  220. result=$(bash "$MAIL_SCRIPT" nonexistent 2>&1)
  221. exit_code=$?
  222. assert_exit_code "unknown command fails" "1" "$exit_code"
  223. echo ""
  224. echo "=== Input Validation ==="
  225. # T28: Non-numeric message ID rejected
  226. result=$(bash "$MAIL_SCRIPT" read "abc" 2>&1)
  227. exit_code=$?
  228. assert_exit_code "non-numeric ID rejected" "1" "$exit_code"
  229. # T29: SQL injection via message ID
  230. bash "$MAIL_SCRIPT" send "claude-mods" "id-inject-test" "before injection" >/dev/null 2>&1
  231. result=$(bash "$MAIL_SCRIPT" read "1 OR 1=1" 2>&1)
  232. exit_code=$?
  233. assert_exit_code "SQL injection via ID rejected" "1" "$exit_code"
  234. # T30: Non-numeric limit in list
  235. result=$(bash "$MAIL_SCRIPT" list "abc" 2>&1)
  236. exit_code=$?
  237. assert_exit_code "non-numeric limit handled" "0" "$exit_code"
  238. # T31: Non-numeric days in clear
  239. result=$(bash "$MAIL_SCRIPT" clear "abc" 2>&1)
  240. assert_contains "non-numeric days handled" "Cleared" "$result"
  241. # T32: Single quotes in subject preserved
  242. bash "$MAIL_SCRIPT" read >/dev/null 2>&1 # clear unread
  243. bash "$MAIL_SCRIPT" send "claude-mods" "it's working" "body with 'quotes'" >/dev/null 2>&1
  244. result=$(bash "$MAIL_SCRIPT" read 2>&1)
  245. assert_contains "single quotes in subject" "it's working" "$result"
  246. # T33: Double quotes in body preserved
  247. bash "$MAIL_SCRIPT" send "claude-mods" "quotes" 'She said "hello"' >/dev/null 2>&1
  248. result=$(bash "$MAIL_SCRIPT" read 2>&1)
  249. assert_contains "double quotes in body" "hello" "$result"
  250. # T34: Project name with spaces (edge case)
  251. bash "$MAIL_SCRIPT" send "my project" "spaces" "project name has spaces" >/dev/null 2>&1
  252. result=$(bash "$MAIL_SCRIPT" projects)
  253. assert_contains "project with spaces stored" "my project" "$result"
  254. # T35: Multiple rapid sends
  255. for i in 1 2 3 4 5; do
  256. bash "$MAIL_SCRIPT" send "claude-mods" "rapid-$i" "rapid fire test $i" >/dev/null 2>&1
  257. done
  258. result=$(bash "$MAIL_SCRIPT" count)
  259. assert "5 rapid sends all counted" "5" "$result"
  260. bash "$MAIL_SCRIPT" read >/dev/null 2>&1
  261. # T36: Init is idempotent
  262. bash "$MAIL_SCRIPT" init >/dev/null 2>&1
  263. bash "$MAIL_SCRIPT" init >/dev/null 2>&1
  264. result=$(bash "$MAIL_SCRIPT" count)
  265. assert "init idempotent" "0" "$result"
  266. # T37: Empty subject defaults
  267. result=$(bash "$MAIL_SCRIPT" send "claude-mods" "" "empty subject body" 2>&1)
  268. assert_contains "empty subject accepted" "Sent to claude-mods" "$result"
  269. bash "$MAIL_SCRIPT" read >/dev/null 2>&1
  270. echo ""
  271. echo "=== Reply ==="
  272. # T38: Reply to a message
  273. bash "$MAIL_SCRIPT" send "claude-mods" "Original msg" "Please reply" >/dev/null 2>&1
  274. msg_id=$(sqlite3 "$MAIL_DB" "SELECT id FROM messages WHERE subject='Original msg' AND read=0 LIMIT 1;")
  275. bash "$MAIL_SCRIPT" read "$msg_id" >/dev/null 2>&1
  276. result=$(bash "$MAIL_SCRIPT" reply "$msg_id" "Here is my reply" 2>&1)
  277. assert_contains "reply succeeds" "Replied to claude-mods" "$result"
  278. assert_contains "reply has Re: prefix" "Re: Original msg" "$result"
  279. # T39: Reply to nonexistent message
  280. result=$(bash "$MAIL_SCRIPT" reply 99999 "reply to nothing" 2>&1)
  281. exit_code=$?
  282. assert_exit_code "reply to nonexistent fails" "1" "$exit_code"
  283. # T40: Reply with empty body
  284. result=$(bash "$MAIL_SCRIPT" reply "$msg_id" "" 2>&1)
  285. exit_code=$?
  286. assert_exit_code "reply with empty body fails" "1" "$exit_code"
  287. # T41: Reply with non-numeric ID
  288. result=$(bash "$MAIL_SCRIPT" reply "abc" "body" 2>&1)
  289. exit_code=$?
  290. assert_exit_code "reply with non-numeric ID fails" "1" "$exit_code"
  291. # Clean up
  292. bash "$MAIL_SCRIPT" read >/dev/null 2>&1
  293. echo ""
  294. echo "=== Priority & Search ==="
  295. # T38: Send urgent message
  296. result=$(bash "$MAIL_SCRIPT" send --urgent "claude-mods" "Server down" "Production is on fire" 2>&1)
  297. assert_contains "urgent send succeeds" "URGENT" "$result"
  298. # T39: Hook highlights urgent
  299. rm -f /tmp/agentmail_check_* 2>/dev/null
  300. result=$(bash "$HOOK_SCRIPT" 2>&1)
  301. assert_contains "hook shows URGENT" "URGENT" "$result"
  302. assert_contains "hook shows [!] prefix" "[!]" "$result"
  303. bash "$MAIL_SCRIPT" read >/dev/null 2>&1
  304. # T40: Normal send still works after priority feature
  305. result=$(bash "$MAIL_SCRIPT" send "claude-mods" "Normal msg" "not urgent" 2>&1)
  306. TOTAL=$((TOTAL + 1))
  307. if echo "$result" | grep -qvF "URGENT"; then
  308. echo "PASS: normal send has no URGENT tag"
  309. PASS=$((PASS + 1))
  310. else
  311. echo "FAIL: normal send incorrectly tagged URGENT"
  312. FAIL=$((FAIL + 1))
  313. fi
  314. bash "$MAIL_SCRIPT" read >/dev/null 2>&1
  315. # T41: Search by keyword in subject
  316. bash "$MAIL_SCRIPT" send "claude-mods" "API endpoint changed" "details here" >/dev/null 2>&1
  317. bash "$MAIL_SCRIPT" send "claude-mods" "unrelated" "nothing relevant" >/dev/null 2>&1
  318. result=$(bash "$MAIL_SCRIPT" search "API" 2>&1)
  319. assert_contains "search finds by subject" "API endpoint" "$result"
  320. # T42: Search by keyword in body
  321. result=$(bash "$MAIL_SCRIPT" search "relevant" 2>&1)
  322. assert_contains "search finds by body" "unrelated" "$result"
  323. # T43: Search with no results
  324. result=$(bash "$MAIL_SCRIPT" search "xyznonexistent" 2>&1)
  325. assert_empty "search no results is empty" "$result"
  326. # T44: Search with no keyword fails
  327. result=$(bash "$MAIL_SCRIPT" search 2>&1)
  328. exit_code=$?
  329. assert_exit_code "search no keyword fails" "1" "$exit_code"
  330. bash "$MAIL_SCRIPT" read >/dev/null 2>&1
  331. echo ""
  332. echo "=== Broadcast & Status ==="
  333. # Setup: ensure multiple projects exist
  334. bash "$MAIL_SCRIPT" send "project-a" "setup" "creating project-a" >/dev/null 2>&1
  335. bash "$MAIL_SCRIPT" send "project-b" "setup" "creating project-b" >/dev/null 2>&1
  336. # T42: Broadcast sends to all known projects except self
  337. result=$(bash "$MAIL_SCRIPT" broadcast "Announcement" "Main is frozen" 2>&1)
  338. assert_contains "broadcast reports count" "Broadcast to" "$result"
  339. # T43: Broadcast doesn't send to self
  340. self_count=$(sqlite3 "$MAIL_DB" "SELECT COUNT(*) FROM messages WHERE to_project='claude-mods' AND subject='Announcement';")
  341. assert "broadcast skips self" "0" "$self_count"
  342. # T44: Broadcast with empty body fails
  343. result=$(bash "$MAIL_SCRIPT" broadcast "test" "" 2>&1)
  344. exit_code=$?
  345. assert_exit_code "broadcast empty body fails" "1" "$exit_code"
  346. # T45: Status shows inbox summary
  347. bash "$MAIL_SCRIPT" send "claude-mods" "Status test 1" "msg1" >/dev/null 2>&1
  348. bash "$MAIL_SCRIPT" send "claude-mods" "Status test 2" "msg2" >/dev/null 2>&1
  349. result=$(bash "$MAIL_SCRIPT" status 2>&1)
  350. assert_contains "status shows unread count" "unread" "$result"
  351. assert_contains "status shows Inbox" "Inbox" "$result"
  352. # T46: Status on empty inbox
  353. bash "$MAIL_SCRIPT" read >/dev/null 2>&1
  354. result=$(bash "$MAIL_SCRIPT" status 2>&1)
  355. assert_contains "status shows 0 unread" "0 unread" "$result"
  356. echo ""
  357. echo "=== Alias (Rename) ==="
  358. # Setup: send messages with old project name
  359. bash "$MAIL_SCRIPT" send "old-project" "before rename" "testing alias" >/dev/null 2>&1
  360. bash "$MAIL_SCRIPT" send "claude-mods" "from old" "message from old name" >/dev/null 2>&1
  361. # T47: Alias renames in all messages
  362. result=$(bash "$MAIL_SCRIPT" alias "old-project" "new-project" 2>&1)
  363. assert_contains "alias reports rename" "Renamed" "$result"
  364. assert_contains "alias shows old name" "old-project" "$result"
  365. assert_contains "alias shows new name" "new-project" "$result"
  366. # T48: Old project name no longer appears
  367. result=$(bash "$MAIL_SCRIPT" projects)
  368. TOTAL=$((TOTAL + 1))
  369. if echo "$result" | grep -qF "old-project"; then
  370. echo "FAIL: old project name still present after alias"
  371. FAIL=$((FAIL + 1))
  372. else
  373. echo "PASS: old project name removed after alias"
  374. PASS=$((PASS + 1))
  375. fi
  376. # T49: New project name appears
  377. assert_contains "new project name present" "new-project" "$result"
  378. # T50: Alias with missing args fails
  379. result=$(bash "$MAIL_SCRIPT" alias "only-one" 2>&1)
  380. exit_code=$?
  381. assert_exit_code "alias with missing arg fails" "1" "$exit_code"
  382. # Clean up
  383. bash "$MAIL_SCRIPT" read >/dev/null 2>&1
  384. echo ""
  385. echo "=== Performance ==="
  386. # T38: Hook cooldown - second call within cooldown is silent even with mail
  387. bash "$MAIL_SCRIPT" send "claude-mods" "cooldown test" "testing cooldown" >/dev/null 2>&1
  388. # Clear any cooldown files for current PID
  389. rm -f /tmp/agentmail_check_* 2>/dev/null
  390. # First call should show mail
  391. result1=$(bash "$HOOK_SCRIPT" 2>&1)
  392. assert_contains "hook fires on first call" "MAIL" "$result1"
  393. # Note: can't easily test cooldown across separate bash invocations since PID changes
  394. # But we can verify the cooldown file was created
  395. bash "$MAIL_SCRIPT" read >/dev/null 2>&1
  396. echo ""
  397. echo "=== Per-Project Disable ==="
  398. # T52: Hook respects .claude/agentmail.disable
  399. bash "$MAIL_SCRIPT" send "claude-mods" "disable test" "should not appear" >/dev/null 2>&1
  400. rm -f /tmp/agentmail_check_* 2>/dev/null
  401. mkdir -p .claude
  402. touch .claude/agentmail.disable
  403. result=$(bash "$HOOK_SCRIPT" 2>&1)
  404. assert_empty "hook silent when disabled" "$result"
  405. # T53: Hook works again after removing disable file
  406. rm -f .claude/agentmail.disable
  407. rm -f /tmp/agentmail_check_* 2>/dev/null
  408. result=$(bash "$HOOK_SCRIPT" 2>&1)
  409. assert_contains "hook works after re-enable" "MAIL" "$result"
  410. bash "$MAIL_SCRIPT" read >/dev/null 2>&1
  411. echo ""
  412. echo "=== Results ==="
  413. echo "Passed: $PASS / $TOTAL"
  414. echo "Failed: $FAIL / $TOTAL"
  415. echo ""
  416. echo "$PASS"