summaryrefslogtreecommitdiffstats
path: root/hugolib/alias_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'hugolib/alias_test.go')
-rw-r--r--hugolib/alias_test.go33
1 files changed, 22 insertions, 11 deletions
diff --git a/hugolib/alias_test.go b/hugolib/alias_test.go
index b0491c13e..17c663496 100644
--- a/hugolib/alias_test.go
+++ b/hugolib/alias_test.go
@@ -45,18 +45,29 @@ func TestAlias(t *testing.T) {
t.Parallel()
c := qt.New(t)
- b := newTestSitesBuilder(t)
- b.WithSimpleConfigFile().WithContent("blog/page.md", pageWithAlias)
- b.CreateSites().Build(BuildCfg{})
-
- c.Assert(len(b.H.Sites), qt.Equals, 1)
- c.Assert(len(b.H.Sites[0].RegularPages()), qt.Equals, 1)
+ tests := []struct {
+ urlPrefix string
+ settings map[string]interface{}
+ }{
+ {"http://example.com", map[string]interface{}{"baseURL": "http://example.com"}},
+ {"http://example.com", map[string]interface{}{"baseURL": "http://example.com", "canonifyURLs": true}},
+ {"../..", map[string]interface{}{"relativeURLs": true}},
+ }
- // the real page
- b.AssertFileContent("public/blog/page/index.html", "For some moments the old man")
- // the alias redirectors
- b.AssertFileContent("public/foo/bar/index.html", "<meta http-equiv=\"refresh\" content=\"0; ")
- b.AssertFileContent("public/blog/rel/index.html", "<meta http-equiv=\"refresh\" content=\"0; ")
+ for _, test := range tests {
+ b := newTestSitesBuilder(t)
+ b.WithSimpleConfigFileAndSettings(test.settings).WithContent("blog/page.md", pageWithAlias)
+ b.CreateSites().Build(BuildCfg{})
+
+ c.Assert(len(b.H.Sites), qt.Equals, 1)
+ c.Assert(len(b.H.Sites[0].RegularPages()), qt.Equals, 1)
+
+ // the real page
+ b.AssertFileContent("public/blog/page/index.html", "For some moments the old man")
+ // the alias redirectors
+ b.AssertFileContent("public/foo/bar/index.html", "<meta http-equiv=\"refresh\" content=\"0; url="+test.urlPrefix+"/blog/page/\" />")
+ b.AssertFileContent("public/blog/rel/index.html", "<meta http-equiv=\"refresh\" content=\"0; url="+test.urlPrefix+"/blog/page/\" />")
+ }
}
func TestAliasMultipleOutputFormats(t *testing.T) {