diff options
author | Stef Walter <stef@thewalter.net> | 2015-11-08 13:18:07 +0100 |
---|---|---|
committer | Stef Walter <stef@thewalter.net> | 2016-02-05 17:07:01 +0100 |
commit | c059b62fe696516855813ff03f432375333a2737 (patch) | |
tree | 3e173c0be590bdb696ec905e8b8cb6c25bb95be1 /src/journal/test-catalog.c | |
parent | 9d85882aa8ef1c54171419703f48d59d9df1b75c (diff) |
journal: Add test for merging journal entries
Diffstat (limited to 'src/journal/test-catalog.c')
-rw-r--r-- | src/journal/test-catalog.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/journal/test-catalog.c b/src/journal/test-catalog.c index b03a16d2fc..ae936f6419 100644 --- a/src/journal/test-catalog.c +++ b/src/journal/test-catalog.c @@ -109,6 +109,73 @@ static void test_catalog_import_one(void) { } } +static void test_catalog_import_merge(void) { + _cleanup_hashmap_free_free_free_ Hashmap *h = NULL; + char *payload; + Iterator j; + + const char *input = +"-- 0027229ca0644181a76c4e92458afaff dededededededededededededededed\n" \ +"Subject: message\n" \ +"Defined-By: me\n" \ +"\n" \ +"payload\n" \ +"\n" \ +"-- 0027229ca0644181a76c4e92458afaff dededededededededededededededed\n" \ +"Subject: override subject\n" \ +"X-Header: hello\n" \ +"\n" \ +"override payload\n"; + + const char *combined = +"Subject: override subject\n" \ +"X-Header: hello\n" \ +"Subject: message\n" \ +"Defined-By: me\n" \ +"\n" \ +"override payload\n"; + + h = test_import(input, -1, 0); + assert_se(hashmap_size(h) == 1); + + HASHMAP_FOREACH(payload, h, j) { + assert_se(streq(combined, payload)); + } +} + +static void test_catalog_import_merge_no_body(void) { + _cleanup_hashmap_free_free_free_ Hashmap *h = NULL; + char *payload; + Iterator j; + + const char *input = +"-- 0027229ca0644181a76c4e92458afaff dededededededededededededededed\n" \ +"Subject: message\n" \ +"Defined-By: me\n" \ +"\n" \ +"payload\n" \ +"\n" \ +"-- 0027229ca0644181a76c4e92458afaff dededededededededededededededed\n" \ +"Subject: override subject\n" \ +"X-Header: hello\n" \ +"\n"; + + const char *combined = +"Subject: override subject\n" \ +"X-Header: hello\n" \ +"Subject: message\n" \ +"Defined-By: me\n" \ +"\n" \ +"payload\n"; + + h = test_import(input, -1, 0); + assert_se(hashmap_size(h) == 1); + + HASHMAP_FOREACH(payload, h, j) { + assert_se(streq(combined, payload)); + } +} + static const char* database = NULL; static void test_catalog_update(void) { @@ -176,6 +243,8 @@ int main(int argc, char *argv[]) { test_catalog_import_invalid(); test_catalog_import_badid(); test_catalog_import_one(); + test_catalog_import_merge(); + test_catalog_import_merge_no_body(); test_catalog_update(); |