diff options
author | Noah Campbell <noahcampbell@gmail.com> | 2013-10-07 08:53:18 +0300 |
---|---|---|
committer | Noah Campbell <noahcampbell@gmail.com> | 2013-10-08 18:44:15 +0200 |
commit | 6e1268f45be9995c3d503fa34bb5f63a63f49e00 (patch) | |
tree | d33f96fc408cc9265c3712409cd6e1798191a01a /hugolib/page_permalink_test.go | |
parent | 895638433e52956b8af97dd14f134cb9486d3bdd (diff) |
Test case for permalink functionality
Diffstat (limited to 'hugolib/page_permalink_test.go')
-rw-r--r-- | hugolib/page_permalink_test.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/hugolib/page_permalink_test.go b/hugolib/page_permalink_test.go index d318505b8..e40a78362 100644 --- a/hugolib/page_permalink_test.go +++ b/hugolib/page_permalink_test.go @@ -1,9 +1,47 @@ package hugolib import ( + "html/template" "testing" ) func TestPermalink(t *testing.T) { + tests := []struct { + base template.URL + expectedAbs string + expectedRel string + }{ + {"", "/x/y/z/boofar", "/x/y/z/boofar"}, + {"http://barnew/", "http://barnew/x/y/z/boofar", "/x/y/z/boofar"}, + } + for _, test := range tests { + p := &Page{ + Node: Node{ + UrlPath: UrlPath{Section: "x/y/z"}, + Site: SiteInfo{BaseUrl: test.base}, + }, + File: File{FileName: "x/y/z/boofar.md"}, + } + + u, err := p.Permalink() + if err != nil { + t.Errorf("Unable to process permalink: %s", err) + } + + expected := test.expectedAbs + if u != expected { + t.Errorf("Expected abs url: %s, got: %s", expected, u) + } + + u, err = p.RelPermalink() + if err != nil { + t.Errorf("Unable to process permalink: %s", err) + } + + expected = test.expectedRel + if u != expected { + t.Errorf("Expected abs url: %s, got: %s", expected, u) + } + } } |