From 4bfa321f784683cef90f63f83d1aa7fe741a196e Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Wed, 25 Jul 2018 21:50:06 +0200 Subject: make: implemented atom_legacy_entry_id setting This allows current users to avoid atom entry id changes. --- tests/blogc-make/check_atom.c | 128 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) (limited to 'tests') diff --git a/tests/blogc-make/check_atom.c b/tests/blogc-make/check_atom.c index ac68e67..f58f2ba 100644 --- a/tests/blogc-make/check_atom.c +++ b/tests/blogc-make/check_atom.c @@ -269,6 +269,132 @@ test_atom_dir(void **state) } +static void +test_atom_legacy_entry_id_empty(void **state) +{ + bm_settings_t *settings = bc_malloc(sizeof(bm_settings_t)); + settings->settings = bc_trie_new(free); + bc_trie_insert(settings->settings, "atom_prefix", bc_strdup("")); + bc_trie_insert(settings->settings, "atom_ext", bc_strdup(".xml")); + bc_trie_insert(settings->settings, "post_prefix", bc_strdup("")); + bc_trie_insert(settings->settings, "html_ext", bc_strdup(".html")); + bc_trie_insert(settings->settings, "atom_legacy_entry_id", bc_strdup("1")); + + bc_error_t *err = NULL; + char *rv = bm_atom_deploy(settings, &err); + + assert_non_null(rv); + assert_null(err); + + size_t cmp_len; + char *cmp = bc_file_get_contents(rv, true, &cmp_len, &err); + + assert_non_null(cmp); + assert_null(err); + + assert_string_equal(cmp, + "\n" + "\n" + " {{ SITE_TITLE }}{% ifdef FILTER_TAG %} - " + "{{ FILTER_TAG }}{% endif %}\n" + " {{ BASE_URL }}{% ifdef FILTER_TAG %}/{{ FILTER_TAG }}" + "{% else %}/index{% endif %}.xml\n" + " {{ DATE_FIRST_FORMATTED }}\n" + " \n" + " \n" + " \n" + " {{ AUTHOR_NAME }}\n" + " {{ AUTHOR_EMAIL }}\n" + " \n" + " {{ SITE_TAGLINE }}\n" + " {% block listing %}\n" + " \n" + " {{ TITLE }}\n" + " {{ BASE_URL }}/{{ FILENAME }}/\n" + " {{ DATE_FORMATTED }}\n" + " {{ DATE_FORMATTED }}\n" + " \n" + " \n" + " {{ AUTHOR_NAME }}\n" + " {{ AUTHOR_EMAIL }}\n" + " \n" + " \n" + " \n" + " {% endblock %}\n" + "\n"); + + free(cmp); + bm_atom_destroy(rv); + free(rv); + bc_trie_free(settings->settings); + free(settings); +} + + +static void +test_atom_legacy_entry_id(void **state) +{ + bm_settings_t *settings = bc_malloc(sizeof(bm_settings_t)); + settings->settings = bc_trie_new(free); + bc_trie_insert(settings->settings, "atom_prefix", bc_strdup("atom")); + bc_trie_insert(settings->settings, "atom_ext", bc_strdup(".xml")); + bc_trie_insert(settings->settings, "post_prefix", bc_strdup("post")); + bc_trie_insert(settings->settings, "html_ext", bc_strdup(".html")); + bc_trie_insert(settings->settings, "atom_legacy_entry_id", bc_strdup("1")); + + bc_error_t *err = NULL; + char *rv = bm_atom_deploy(settings, &err); + + assert_non_null(rv); + assert_null(err); + + size_t cmp_len; + char *cmp = bc_file_get_contents(rv, true, &cmp_len, &err); + + assert_non_null(cmp); + assert_null(err); + + assert_string_equal(cmp, + "\n" + "\n" + " {{ SITE_TITLE }}{% ifdef FILTER_TAG %} - " + "{{ FILTER_TAG }}{% endif %}\n" + " {{ BASE_URL }}/atom{% ifdef FILTER_TAG %}/{{ FILTER_TAG }}" + "{% endif %}.xml\n" + " {{ DATE_FIRST_FORMATTED }}\n" + " \n" + " \n" + " \n" + " {{ AUTHOR_NAME }}\n" + " {{ AUTHOR_EMAIL }}\n" + " \n" + " {{ SITE_TAGLINE }}\n" + " {% block listing %}\n" + " \n" + " {{ TITLE }}\n" + " {{ BASE_URL }}/post/{{ FILENAME }}/\n" + " {{ DATE_FORMATTED }}\n" + " {{ DATE_FORMATTED }}\n" + " \n" + " \n" + " {{ AUTHOR_NAME }}\n" + " {{ AUTHOR_EMAIL }}\n" + " \n" + " \n" + " \n" + " {% endblock %}\n" + "\n"); + + free(cmp); + bm_atom_destroy(rv); + free(rv); + bc_trie_free(settings->settings); + free(settings); +} + + int main(void) { @@ -277,6 +403,8 @@ main(void) unit_test(test_atom_empty_dir), unit_test(test_atom_file), unit_test(test_atom_dir), + unit_test(test_atom_legacy_entry_id_empty), + unit_test(test_atom_legacy_entry_id), }; return run_tests(tests); } -- cgit v1.2.3-18-g5258