summaryrefslogtreecommitdiffstats
path: root/hugolib/node_as_page_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-11-15 10:43:49 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-11-22 09:57:03 +0100
commit524eb16686bed7d110c6001c5d98b2ee0a2d80ee (patch)
tree89c9e677cf91c730b252a7e0c7d497e7501d58ca /hugolib/node_as_page_test.go
parentc8d3124ddeb86093caf1b18dfaa328c3053e5b63 (diff)
node to page: Handle URLs
This includes removing the error return value from Permalink and RelPermalink. We ignore that error all over the place, so we might as well remove it. Updates #2297
Diffstat (limited to 'hugolib/node_as_page_test.go')
-rw-r--r--hugolib/node_as_page_test.go44
1 files changed, 43 insertions, 1 deletions
diff --git a/hugolib/node_as_page_test.go b/hugolib/node_as_page_test.go
index 1c091821f..daebee092 100644
--- a/hugolib/node_as_page_test.go
+++ b/hugolib/node_as_page_test.go
@@ -394,6 +394,7 @@ aliases:
`)
viper.Set("paginate", 1)
+ viper.Set("baseURL", "http://base/")
viper.Set("title", "Hugo Rocks!")
s := newSiteDefaultLang()
@@ -403,7 +404,7 @@ aliases:
}
assertFileContent(t, filepath.Join("public", "index.html"), true, "Home With Alias")
- assertFileContent(t, filepath.Join("public", "my", "new", "home.html"), true, "content=\"0; url=/")
+ assertFileContent(t, filepath.Join("public", "my", "new", "home.html"), true, "content=\"0; url=http://base/")
}
@@ -431,6 +432,47 @@ My Section Content
}
+func TestNodesWithURLs(t *testing.T) {
+ testCommonResetState()
+
+ writeLayoutsForNodeAsPageTests(t)
+
+ writeRegularPagesForNodeAsPageTests(t)
+
+ writeSource(t, filepath.Join("content", "sect", "_index.md"), `---
+title: MySection
+url: foo.html
+---
+My Section Content
+`)
+
+ viper.Set("paginate", 1)
+ viper.Set("title", "Hugo Rocks!")
+ viper.Set("baseURL", "http://bep.is/base/")
+
+ s := newSiteDefaultLang()
+
+ if err := buildAndRenderSite(s); err != nil {
+ t.Fatalf("Failed to build site: %s", err)
+ }
+
+ assertFileContent(t, filepath.Join("public", "sect", "index.html"), true, "My Section")
+
+ p := s.RegularPages[0]
+
+ require.Equal(t, "/base/sect1/regular1/", p.URL())
+
+ // Section with front matter and url set (which should not be used)
+ sect := s.getPage(KindSection, "sect")
+ require.Equal(t, "/base/sect/", sect.URL())
+ require.Equal(t, "http://bep.is/base/sect/", sect.Permalink())
+ require.Equal(t, "/base/sect/", sect.RelPermalink())
+
+ // Home page without front matter
+ require.Equal(t, "/base/", s.getPage(KindHome).URL())
+
+}
+
func writeRegularPagesForNodeAsPageTests(t *testing.T) {
writeRegularPagesForNodeAsPageTestsWithLang(t, "")
}