#!/usr/bin/env bash test_description='"notmuch address" in several variants' . ./test-lib.sh add_email_corpus test_begin_subtest "--output=sender" notmuch address --output=sender '*' >OUTPUT cat <EXPECTED François Boulogne Olivier Berger Chris Wilson Carl Worth Alexander Botero-Lowry Keith Packard Jjgod Jiang Rolland Santimano Jan Janak Stewart Smith Lars Kellogg-Stedman Alex Botero-Lowry Ingmar Vanhassel Aron Griffis Adrian Perez de Castro Israel Herraiz Mikhail Gusarov EOF test_expect_equal_file OUTPUT EXPECTED test_begin_subtest "--output=sender --format=json" notmuch address --output=sender --format=json '*' >OUTPUT cat <EXPECTED [{"name": "François Boulogne", "address": "boulogne.f@gmail.com", "name-addr": "François Boulogne "}, {"name": "Olivier Berger", "address": "olivier.berger@it-sudparis.eu", "name-addr": "Olivier Berger "}, {"name": "Chris Wilson", "address": "chris@chris-wilson.co.uk", "name-addr": "Chris Wilson "}, {"name": "Carl Worth", "address": "cworth@cworth.org", "name-addr": "Carl Worth "}, {"name": "Alexander Botero-Lowry", "address": "alex.boterolowry@gmail.com", "name-addr": "Alexander Botero-Lowry "}, {"name": "Keith Packard", "address": "keithp@keithp.com", "name-addr": "Keith Packard "}, {"name": "Jjgod Jiang", "address": "gzjjgod@gmail.com", "name-addr": "Jjgod Jiang "}, {"name": "Rolland Santimano", "address": "rollandsantimano@yahoo.com", "name-addr": "Rolland Santimano "}, {"name": "Jan Janak", "address": "jan@ryngle.com", "name-addr": "Jan Janak "}, {"name": "Stewart Smith", "address": "stewart@flamingspork.com", "name-addr": "Stewart Smith "}, {"name": "Lars Kellogg-Stedman", "address": "lars@seas.harvard.edu", "name-addr": "Lars Kellogg-Stedman "}, {"name": "Alex Botero-Lowry", "address": "alex.boterolowry@gmail.com", "name-addr": "Alex Botero-Lowry "}, {"name": "Ingmar Vanhassel", "address": "ingmar@exherbo.org", "name-addr": "Ingmar Vanhassel "}, {"name": "Aron Griffis", "address": "agriffis@n01se.net", "name-addr": "Aron Griffis "}, {"name": "Adrian Perez de Castro", "address": "aperez@igalia.com", "name-addr": "Adrian Perez de Castro "}, {"name": "Israel Herraiz", "address": "isra@herraiz.org", "name-addr": "Israel Herraiz "}, {"name": "Mikhail Gusarov", "address": "dottedmag@dottedmag.net", "name-addr": "Mikhail Gusarov "}] EOF test_expect_equal_file OUTPUT EXPECTED test_begin_subtest "--output=recipients" notmuch address --output=recipients '*' >OUTPUT cat <EXPECTED Allan McRae "Discussion about the Arch User Repository (AUR)" olivier.berger@it-sudparis.eu notmuch@notmuchmail.org notmuch Keith Packard Mikhail Gusarov EOF test_expect_equal_file OUTPUT EXPECTED test_begin_subtest "--output=sender --output=recipients" notmuch address --output=sender --output=recipients '*' >OUTPUT cat <EXPECTED François Boulogne Allan McRae "Discussion about the Arch User Repository (AUR)" Olivier Berger olivier.berger@it-sudparis.eu Chris Wilson notmuch@notmuchmail.org Carl Worth Alexander Botero-Lowry Keith Packard Jjgod Jiang Rolland Santimano Jan Janak Stewart Smith Lars Kellogg-Stedman notmuch Alex Botero-Lowry Ingmar Vanhassel Aron Griffis Adrian Perez de Castro Israel Herraiz Mikhail Gusarov EOF test_expect_equal_file OUTPUT EXPECTED test_begin_subtest "without --output" notmuch address '*' >OUTPUT # Use EXPECTED from previous subtest test_expect_equal_file OUTPUT EXPECTED test_begin_subtest "--output=sender --output=count" notmuch address --output=sender --output=count '*' | sort -n >OUTPUT cat <EXPECTED 1 Adrian Perez de Castro 1 Aron Griffis 1 Chris Wilson 1 François Boulogne 1 Ingmar Vanhassel 1 Israel Herraiz 1 Olivier Berger 1 Rolland Santimano 2 Alex Botero-Lowry 2 Jjgod Jiang 3 Stewart Smith 4 Alexander Botero-Lowry 4 Jan Janak 5 Lars Kellogg-Stedman 5 Mikhail Gusarov 7 Keith Packard 12 Carl Worth EOF test_expect_equal_file OUTPUT EXPECTED test_begin_subtest "--output=sender --output=count --format=json" # Since the iteration order of GHashTable is not specified, we # preprocess and sort the results to keep the order stable here. notmuch address --output=sender --output=count --format=json '*' | \ sed -e 's/^\[//' -e 's/]$//' -e 's/,$//' | sort >OUTPUT cat <EXPECTED {"name": "Adrian Perez de Castro", "address": "aperez@igalia.com", "name-addr": "Adrian Perez de Castro ", "count": 1} {"name": "Alex Botero-Lowry", "address": "alex.boterolowry@gmail.com", "name-addr": "Alex Botero-Lowry ", "count": 2} {"name": "Alexander Botero-Lowry", "address": "alex.boterolowry@gmail.com", "name-addr": "Alexander Botero-Lowry ", "count": 4} {"name": "Aron Griffis", "address": "agriffis@n01se.net", "name-addr": "Aron Griffis ", "count": 1} {"name": "Carl Worth", "address": "cworth@cworth.org", "name-addr": "Carl Worth ", "count": 12} {"name": "Chris Wilson", "address": "chris@chris-wilson.co.uk", "name-addr": "Chris Wilson ", "count": 1} {"name": "François Boulogne", "address": "boulogne.f@gmail.com", "name-addr": "François Boulogne ", "count": 1} {"name": "Ingmar Vanhassel", "address": "ingmar@exherbo.org", "name-addr": "Ingmar Vanhassel ", "count": 1} {"name": "Israel Herraiz", "address": "isra@herraiz.org", "name-addr": "Israel Herraiz ", "count": 1} {"name": "Jan Janak", "address": "jan@ryngle.com", "name-addr": "Jan Janak ", "count": 4} {"name": "Jjgod Jiang", "address": "gzjjgod@gmail.com", "name-addr": "Jjgod Jiang ", "count": 2} {"name": "Keith Packard", "address": "keithp@keithp.com", "name-addr": "Keith Packard ", "count": 7} {"name": "Lars Kellogg-Stedman", "address": "lars@seas.harvard.edu", "name-addr": "Lars Kellogg-Stedman ", "count": 5} {"name": "Mikhail Gusarov", "address": "dottedmag@dottedmag.net", "name-addr": "Mikhail Gusarov ", "count": 5} {"name": "Olivier Berger", "address": "olivier.berger@it-sudparis.eu", "name-addr": "Olivier Berger ", "count": 1} {"name": "Rolland Santimano", "address": "rollandsantimano@yahoo.com", "name-addr": "Rolland Santimano ", "count": 1} {"name": "Stewart Smith", "address": "stewart@flamingspork.com", "name-addr": "Stewart Smith ", "count": 3} EOF test_expect_equal_file OUTPUT EXPECTED test_done