aboutsummaryrefslogtreecommitdiffstats
path: root/tests/blogc-make
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2017-08-03 02:44:36 +0200
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2017-08-03 02:44:36 +0200
commit59e1df233e351a91240c02ac55e8d97bda2f0e43 (patch)
tree846932a4e7761dd93188d1533095f252246c83f3 /tests/blogc-make
parent803eb202e9d2d96fbb0de6f0514db2f0ab959d11 (diff)
downloadblogc-59e1df233e351a91240c02ac55e8d97bda2f0e43.tar.gz
blogc-59e1df233e351a91240c02ac55e8d97bda2f0e43.tar.bz2
blogc-59e1df233e351a91240c02ac55e8d97bda2f0e43.zip
make: added 'html_order' and 'atom_order' settings
these settings are used to change the order of the posts on the listings. by default, users are supposed to list their posts from older to newer in the blogcfile, and blogc-make will list them on descending order, both for html listings and atom listings.
Diffstat (limited to 'tests/blogc-make')
-rwxr-xr-xtests/blogc-make/check_blogc_make.sh.in116
-rw-r--r--tests/blogc-make/check_settings.c12
2 files changed, 123 insertions, 5 deletions
diff --git a/tests/blogc-make/check_blogc_make.sh.in b/tests/blogc-make/check_blogc_make.sh.in
index beb1f6c..d27c3c0 100755
--- a/tests/blogc-make/check_blogc_make.sh.in
+++ b/tests/blogc-make/check_blogc_make.sh.in
@@ -77,6 +77,116 @@ rm "${TEMP}/output.txt"
cat > "${TEMP}/expected-index.html" <<EOF
+Listing: Bar - Sep 01, 2016, 12:00 AM GMT
+
+Listing: Foo - Oct 01, 2016, 12:00 AM GMT
+
+
+EOF
+diff -uN "${TEMP}/proj/_build/index.html" "${TEMP}/expected-index.html"
+diff -uN "${TEMP}/proj/_build/page/1/index.html" "${TEMP}/expected-index.html"
+
+cat > "${TEMP}/expected-atom.xml" <<EOF
+<?xml version="1.0" encoding="utf-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+ <title type="text">Lol's Website</title>
+ <id>/atom.xml</id>
+ <updated>2016-09-01T00:00:00Z</updated>
+ <link href="http://example.org/" />
+ <link href="http://example.org/atom.xml" rel="self" />
+ <author>
+ <name>Lol</name>
+ <email>author@example.com</email>
+ </author>
+ <subtitle type="text">WAT?!</subtitle>
+
+ <entry>
+ <title type="text">Bar</title>
+ <id>/post/bar/</id>
+ <updated>2016-09-01T00:00:00Z</updated>
+ <published>2016-09-01T00:00:00Z</published>
+ <link href="http://example.org/post/bar/" />
+ <author>
+ <name>Lol</name>
+ <email>author@example.com</email>
+ </author>
+ <content type="html"><![CDATA[<p>This is bar.</p>
+]]></content>
+ </entry>
+
+ <entry>
+ <title type="text">Foo</title>
+ <id>/post/foo/</id>
+ <updated>2016-10-01T00:00:00Z</updated>
+ <published>2016-10-01T00:00:00Z</published>
+ <link href="http://example.org/post/foo/" />
+ <author>
+ <name>Lol</name>
+ <email>author@example.com</email>
+ </author>
+ <content type="html"><![CDATA[<p>This is foo.</p>
+]]></content>
+ </entry>
+
+</feed>
+EOF
+diff -uN "${TEMP}/proj/_build/atom.xml" "${TEMP}/expected-atom.xml"
+
+cat > "${TEMP}/expected-post-foo.html" <<EOF
+
+
+Foo - Oct 01, 2016, 12:00 AM GMT
+
+<p>This is foo.</p>
+
+
+EOF
+diff -uN "${TEMP}/proj/_build/post/foo/index.html" "${TEMP}/expected-post-foo.html"
+
+cat > "${TEMP}/expected-post-bar.html" <<EOF
+
+
+Bar - Sep 01, 2016, 12:00 AM GMT
+
+<p>This is bar.</p>
+
+
+EOF
+diff -uN "${TEMP}/proj/_build/post/bar/index.html" "${TEMP}/expected-post-bar.html"
+
+rm -rf "${TEMP}/proj/_build"
+
+
+### default settings with some posts, order asc
+
+cat > "${TEMP}/proj/blogcfile" <<EOF
+[global]
+AUTHOR_NAME = Lol
+AUTHOR_EMAIL = author@example.com
+SITE_TITLE = Lol's Website
+SITE_TAGLINE = WAT?!
+BASE_DOMAIN = http://example.org
+
+[settings]
+html_order = ASC
+atom_order = ASC
+
+[posts]
+foo
+bar
+EOF
+
+${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt"
+grep "_build/index\\.html" "${TEMP}/output.txt"
+grep "_build/atom\\.xml" "${TEMP}/output.txt"
+grep "_build/page/1/index\\.html" "${TEMP}/output.txt"
+grep "_build/post/foo/index\\.html" "${TEMP}/output.txt"
+grep "_build/post/bar/index\\.html" "${TEMP}/output.txt"
+
+rm "${TEMP}/output.txt"
+
+cat > "${TEMP}/expected-index.html" <<EOF
+
Listing: Foo - Oct 01, 2016, 12:00 AM GMT
Listing: Bar - Sep 01, 2016, 12:00 AM GMT
@@ -157,7 +267,7 @@ diff -uN "${TEMP}/proj/_build/post/bar/index.html" "${TEMP}/expected-post-bar.ht
rm -rf "${TEMP}/proj/_build"
-### default settings with some posts and tags
+### default settings with some posts and tags, order asc
cat > "${TEMP}/proj/content/post/baz.txt" <<EOF
TITLE: Baz
@@ -357,7 +467,7 @@ diff -uN "${TEMP}/proj/_build/tag/tag2/index.html" "${TEMP}/expected-tag2.html"
rm -rf "${TEMP}/proj/_build"
-### default settings with some posts, pages and tags
+### default settings with some posts, pages and tags, order asc
cat > "${TEMP}/proj/content/page1.txt" <<EOF
TITLE: Page 1
@@ -478,6 +588,8 @@ atom_prefix = atoom
atom_ext = /index.xml
date_format = %b %d, %Y
locale = en_US.utf8
+html_order = ASC
+atom_order = ASC
[global]
AUTHOR_NAME = Lol
diff --git a/tests/blogc-make/check_settings.c b/tests/blogc-make/check_settings.c
index 4016e15..6eaaaec 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), 13);
+ assert_int_equal(bc_trie_size(s->settings), 15);
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");
@@ -141,6 +141,8 @@ test_settings2(void **state)
assert_string_equal(bc_trie_lookup(s->settings, "pagination_prefix"), "page");
assert_string_equal(bc_trie_lookup(s->settings, "post_prefix"), "post");
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_non_null(s->posts);
assert_string_equal(s->posts[0], "aaaa");
assert_string_equal(s->posts[1], "bbbb");
@@ -213,7 +215,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), 13);
+ assert_int_equal(bc_trie_size(s->settings), 15);
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");
@@ -228,6 +230,8 @@ test_settings_env2(void **state)
assert_string_equal(bc_trie_lookup(s->settings, "pagination_prefix"), "page");
assert_string_equal(bc_trie_lookup(s->settings, "post_prefix"), "post");
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_non_null(s->posts);
assert_string_equal(s->posts[0], "aaaa");
assert_string_equal(s->posts[1], "bbbb");
@@ -300,7 +304,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), 13);
+ assert_int_equal(bc_trie_size(s->settings), 15);
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");
@@ -315,6 +319,8 @@ test_settings_copy_files(void **state)
assert_string_equal(bc_trie_lookup(s->settings, "pagination_prefix"), "page");
assert_string_equal(bc_trie_lookup(s->settings, "post_prefix"), "post");
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_non_null(s->posts);
assert_string_equal(s->posts[0], "aaaa");
assert_string_equal(s->posts[1], "bbbb");