home · contact · privacy
Add feed.xml test.
authorChristian Heller <c.heller@plomlompom.de>
Sat, 19 Nov 2016 22:09:54 +0000 (23:09 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Sat, 19 Nov 2016 22:09:54 +0000 (23:09 +0100)
test.sh
test/test_files/feed.xml.ignoring [new file with mode: 0644]

diff --git a/test.sh b/test.sh
index 5a0284d79f18a453e464b319bbb1bd6a2e9ad107..cf6e60c7f8f8e9ad1a16dceb6663178bdfa631ea 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -11,6 +11,19 @@ else
 fi
 }
 
+diff_test()
+{
+  generated_file="$1"
+  expected_file="$2"
+  printf "== %s diff test ==\n" "$generated_file"
+  diff "$expected_file" "$generated_file"
+  if [ "$?" = "0" ]; then
+    echo "== test SUCCESS =="
+  else
+    echo "== test FAILURE =="
+  fi
+}
+
 rm -rf test/test_dir
 ./add_dir.sh test/test_dir
 cp test/test_files/test.md test/test_dir/
@@ -26,12 +39,15 @@ for file in test/test_files/*.html test/test_files/*.meta; do
       echo "$file" | grep -q "\.html$"; then
     uuid_test "${cmp_file%.html}.uuid"
   fi
-  printf "== %s diff test ==\n" "$cmp_file"
-  diff "$file" "$cmp_file"
-  if [ "$?" = "0" ]; then
-    echo "== test SUCCESS =="
-  else
-    echo "== test FAILURE =="
-  fi
+  diff_test "$file" "$cmp_file"
 done
 uuid_test "test/test_dir/uuid.meta"
+original_file="test/test_dir/feed.xml"
+generated_file="$original_file".ignoring
+expected_file="test/test_files/feed.xml.ignoring"
+cat "$original_file" | \
+  sed 's/>[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}T[0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\}Z</>IGNORE</' | \
+  sed 's/>urn:uuid:[0-9a-f]\{8\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{12\}</>urn:uuid:IGNORE</' \
+  > "$generated_file"
+diff_test "$generated_file" "$expected_file"
+rm "$generated_file"
diff --git a/test/test_files/feed.xml.ignoring b/test/test_files/feed.xml.ignoring
new file mode 100644 (file)
index 0000000..039a116
--- /dev/null
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+<link href="http://example.org/" />
+<link href="http://example.org/feed.xml" rel="self" />
+<title type="html">Yet another blog</title>
+<author><name>Joe Sixpack</name></author>
+<id>urn:uuid:IGNORE</id>
+<updated>IGNORE</updated>
+
+<entry>
+<title type="html">foo</title>
+<id>urn:uuid:IGNORE</id>
+<updated>IGNORE</updated>
+<published>IGNORE</published>
+<link href="http://example.org/bar%20baz.html" />
+<content type="html">
+&lt;p&gt;bar&lt;/p&gt;
+</content>
+</entry>
+
+<entry>
+<title type="html">a title with some nasty characters: &amp;amp;&amp;lt;&amp;gt;&amp;quot;&#x27;</title>
+<id>urn:uuid:IGNORE</id>
+<updated>IGNORE</updated>
+<published>IGNORE</published>
+<link href="http://example.org/foo.html" />
+<content type="html">
+&lt;p&gt;this text contains some special characters: &#x27;&amp;quot;&amp;gt;&amp;lt;&amp;amp;&lt;/p&gt;
+&lt;p&gt;and more than one paragraph&lt;/p&gt;
+</content>
+</entry>
+
+<entry>
+<title type="html">foo &lt;em&gt;bar&lt;/em&gt; &lt;strong&gt;baz&lt;/strong&gt;</title>
+<id>urn:uuid:IGNORE</id>
+<updated>IGNORE</updated>
+<published>IGNORE</published>
+<link href="http://example.org/test.html" />
+<content type="html">
+&lt;p&gt;bar&lt;/p&gt;
+</content>
+</entry>
+
+</feed>
\ No newline at end of file