Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Campbell <noahcampbell@gmail.com>2013-10-02 01:26:21 +0400
committerNoah Campbell <noahcampbell@gmail.com>2013-10-08 20:37:50 +0400
commit5a66fa3954f8d4329b2a32fe77c74d953a3c6bb7 (patch)
tree9a21810804e17af8204cc22f220368e801870997 /transform/posttrans_test.go
parenteb117eb9043a4954079f1845f61cc0bfe2facb37 (diff)
Chain transformers and test cases
Transformers can now be chained together, working on the output of the previous run.
Diffstat (limited to 'transform/posttrans_test.go')
-rw-r--r--transform/posttrans_test.go22
1 files changed, 15 insertions, 7 deletions
diff --git a/transform/posttrans_test.go b/transform/posttrans_test.go
index d35847af3..3cac6e76b 100644
--- a/transform/posttrans_test.go
+++ b/transform/posttrans_test.go
@@ -16,19 +16,27 @@ const H5_JS_CONTENT_ABS_URL = "<!DOCTYPE html><html><head><script src=\"http://u
const CORRECT_OUTPUT_SRC_HREF = "<!DOCTYPE html><html><head><script src=\"http://base/foobar.js\"></script></head><body><nav><h1>title</h1></nav><article>content <a href=\"http://base/foobar\">foobar</a>. Follow up</article></body></html>"
func TestAbsUrlify(t *testing.T) {
- tests := []struct {
- content string
- expected string
- }{
+
+ tr := &AbsURL{
+ BaseURL: "http://base",
+ }
+
+ apply(t, tr, abs_url_tests)
+}
+
+type test struct {
+ content string
+ expected string
+}
+
+var abs_url_tests = []test {
{H5_JS_CONTENT_DOUBLE_QUOTE, CORRECT_OUTPUT_SRC_HREF},
{H5_JS_CONTENT_SINGLE_QUOTE, CORRECT_OUTPUT_SRC_HREF},
{H5_JS_CONTENT_ABS_URL, H5_JS_CONTENT_ABS_URL},
}
+func apply(t *testing.T, tr Transformer, tests []test) {
for _, test := range tests {
- tr := &AbsURL{
- BaseURL: "http://base",
- }
out := new(bytes.Buffer)
err := tr.Apply(strings.NewReader(test.content), out)
if err != nil {