aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/blogc-make/check_atom.c62
-rw-r--r--tests/blogc-make/check_settings.c9
2 files changed, 68 insertions, 3 deletions
diff --git a/tests/blogc-make/check_atom.c b/tests/blogc-make/check_atom.c
index 6faa53e..43ed93d 100644
--- a/tests/blogc-make/check_atom.c
+++ b/tests/blogc-make/check_atom.c
@@ -22,6 +22,67 @@
static void
+test_atom_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_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,
+ "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
+ "<feed xmlns=\"http://www.w3.org/2005/Atom\">\n"
+ " <title type=\"text\">{{ SITE_TITLE }}{% ifdef FILTER_TAG %} - "
+ "{{ FILTER_TAG }}{% endif %}</title>\n"
+ " <id>{{ BASE_URL }}{% ifdef FILTER_TAG %}/{{ FILTER_TAG }}"
+ "{% endif %}.xml</id>\n"
+ " <updated>{{ DATE_FIRST_FORMATTED }}</updated>\n"
+ " <link href=\"{{ BASE_DOMAIN }}{{ BASE_URL }}/\" />\n"
+ " <link href=\"{{ BASE_DOMAIN }}{{ BASE_URL }}{% ifdef FILTER_TAG %}"
+ "/{{ FILTER_TAG }}{% endif %}.xml\" rel=\"self\" />\n"
+ " <author>\n"
+ " <name>{{ AUTHOR_NAME }}</name>\n"
+ " <email>{{ AUTHOR_EMAIL }}</email>\n"
+ " </author>\n"
+ " <subtitle type=\"text\">{{ SITE_TAGLINE }}</subtitle>\n"
+ " {% block listing %}\n"
+ " <entry>\n"
+ " <title type=\"text\">{{ TITLE }}</title>\n"
+ " <id>{{ BASE_URL }}/{{ FILENAME }}/</id>\n"
+ " <updated>{{ DATE_FORMATTED }}</updated>\n"
+ " <published>{{ DATE_FORMATTED }}</published>\n"
+ " <link href=\"{{ BASE_DOMAIN }}{{ BASE_URL }}/{{ FILENAME }}/\" />\n"
+ " <author>\n"
+ " <name>{{ AUTHOR_NAME }}</name>\n"
+ " <email>{{ AUTHOR_EMAIL }}</email>\n"
+ " </author>\n"
+ " <content type=\"html\"><![CDATA[{{ CONTENT }}]]></content>\n"
+ " </entry>\n"
+ " {% endblock %}\n"
+ "</feed>\n");
+
+ free(cmp);
+ bm_atom_destroy(rv);
+ free(rv);
+ bc_trie_free(settings->settings);
+ free(settings);
+}
+
+
+static void
test_atom_file(void **state)
{
bm_settings_t *settings = bc_malloc(sizeof(bm_settings_t));
@@ -147,6 +208,7 @@ int
main(void)
{
const UnitTest tests[] = {
+ unit_test(test_atom_empty),
unit_test(test_atom_file),
unit_test(test_atom_dir),
};
diff --git a/tests/blogc-make/check_settings.c b/tests/blogc-make/check_settings.c
index 6eaaaec..8acf7e6 100644
--- a/tests/blogc-make/check_settings.c
+++ b/tests/blogc-make/check_settings.c
@@ -126,7 +126,7 @@ test_settings2(void **state)
assert_string_equal(bc_trie_lookup(s->global, "SITE_TITLE"), "Fuuuuuuuuu");
assert_string_equal(bc_trie_lookup(s->global, "SITE_TAGLINE"), "My cool tagline");
assert_string_equal(bc_trie_lookup(s->global, "BASE_DOMAIN"), "http://example.com");
- assert_int_equal(bc_trie_size(s->settings), 15);
+ assert_int_equal(bc_trie_size(s->settings), 16);
assert_string_equal(bc_trie_lookup(s->settings, "source_ext"), ".txt");
assert_string_equal(bc_trie_lookup(s->settings, "html_ext"), "/index.html");
assert_string_equal(bc_trie_lookup(s->settings, "content_dir"), "guda");
@@ -143,6 +143,7 @@ test_settings2(void **state)
assert_string_equal(bc_trie_lookup(s->settings, "tag_prefix"), "tag");
assert_string_equal(bc_trie_lookup(s->settings, "html_order"), "DESC");
assert_string_equal(bc_trie_lookup(s->settings, "atom_order"), "DESC");
+ assert_string_equal(bc_trie_lookup(s->settings, "index_prefix"), "");
assert_non_null(s->posts);
assert_string_equal(s->posts[0], "aaaa");
assert_string_equal(s->posts[1], "bbbb");
@@ -215,7 +216,7 @@ test_settings_env2(void **state)
assert_string_equal(bc_trie_lookup(s->global, "SITE_TITLE"), "Fuuuuuuuuu");
assert_string_equal(bc_trie_lookup(s->global, "SITE_TAGLINE"), "My cool tagline");
assert_string_equal(bc_trie_lookup(s->global, "BASE_DOMAIN"), "http://example.com");
- assert_int_equal(bc_trie_size(s->settings), 15);
+ assert_int_equal(bc_trie_size(s->settings), 16);
assert_string_equal(bc_trie_lookup(s->settings, "source_ext"), ".txt");
assert_string_equal(bc_trie_lookup(s->settings, "html_ext"), "/index.html");
assert_string_equal(bc_trie_lookup(s->settings, "content_dir"), "guda");
@@ -232,6 +233,7 @@ test_settings_env2(void **state)
assert_string_equal(bc_trie_lookup(s->settings, "tag_prefix"), "tag");
assert_string_equal(bc_trie_lookup(s->settings, "html_order"), "DESC");
assert_string_equal(bc_trie_lookup(s->settings, "atom_order"), "DESC");
+ assert_string_equal(bc_trie_lookup(s->settings, "index_prefix"), "");
assert_non_null(s->posts);
assert_string_equal(s->posts[0], "aaaa");
assert_string_equal(s->posts[1], "bbbb");
@@ -304,7 +306,7 @@ test_settings_copy_files(void **state)
assert_string_equal(bc_trie_lookup(s->global, "SITE_TITLE"), "Fuuuuuuuuu");
assert_string_equal(bc_trie_lookup(s->global, "SITE_TAGLINE"), "My cool tagline");
assert_string_equal(bc_trie_lookup(s->global, "BASE_DOMAIN"), "http://example.com");
- assert_int_equal(bc_trie_size(s->settings), 15);
+ assert_int_equal(bc_trie_size(s->settings), 16);
assert_string_equal(bc_trie_lookup(s->settings, "source_ext"), ".txt");
assert_string_equal(bc_trie_lookup(s->settings, "html_ext"), "/index.html");
assert_string_equal(bc_trie_lookup(s->settings, "content_dir"), "guda");
@@ -321,6 +323,7 @@ test_settings_copy_files(void **state)
assert_string_equal(bc_trie_lookup(s->settings, "tag_prefix"), "tag");
assert_string_equal(bc_trie_lookup(s->settings, "html_order"), "DESC");
assert_string_equal(bc_trie_lookup(s->settings, "atom_order"), "DESC");
+ assert_string_equal(bc_trie_lookup(s->settings, "index_prefix"), "");
assert_non_null(s->posts);
assert_string_equal(s->posts[0], "aaaa");
assert_string_equal(s->posts[1], "bbbb");