test: Move a test from search to search-output, and add a similar json test
authorJameson Graef Rollins <jrollins@finestructure.net>
Fri, 6 May 2011 18:57:16 +0000 (11:57 -0700)
committerCarl Worth <cworth@cworth.org>
Wed, 1 Jun 2011 23:31:52 +0000 (16:31 -0700)
The "Search for non-existent message prints nothing" test fits better
with the existing tests in search-output, so move it there. Also add a
similar test for the --format=json case.

These tests also use the new test_expect_equal_file function, (to ensure
that the presence of a trailing newline is correctly tested).

test/search
test/search-output

index 0981f66d860cec3c0ed13927c5d5b86e4ec685f1..48358729a67b0c4b3b55cea52c514a0d1799f37a 100755 (executable)
@@ -118,9 +118,4 @@ add_message '[subject]="utf8-message-body-subject"' '[date]="Sat, 01 Jan 2000 12
 output=$(notmuch search "bödý" | notmuch_search_sanitize)
 test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; utf8-message-body-subject (inbox unread)"
 
 output=$(notmuch search "bödý" | notmuch_search_sanitize)
 test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; utf8-message-body-subject (inbox unread)"
 
-test_expect_success "Search for non-existent message prints nothing" '
-echo -n > expected &&
-notmuch search "no-message-matches-this" > actual &&
-test_cmp expected actual'
-
 test_done
 test_done
index 1554eb1e93f32c7f84d461eec7687f7c43f8d220..8ba8acf741af29172e97c12a2cac2caa8a54d640 100755 (executable)
@@ -304,4 +304,16 @@ cat <<EOF >EXPECTED
 EOF
 test_expect_equal_file OUTPUT EXPECTED
 
 EOF
 test_expect_equal_file OUTPUT EXPECTED
 
+test_begin_subtest "notmuch search for non-existent message prints nothing"
+notmuch search "no-message-matches-this" > OUTPUT
+echo -n >EXPECTED
+test_expect_equal_file OUTPUT EXPECTED
+
+test_begin_subtest "notmuch search --format=json for non-existent message prints proper empty json"
+notmuch search --format=json "no-message-matches-this" > OUTPUT
+cat <<EOF >EXPECTED
+[]
+EOF
+test_expect_equal_file OUTPUT EXPECTED
+
 test_done
 test_done