// Issue #957
func TestCrossrefs(t *testing.T) {
hugofs.DestinationFS = new(afero.MemMapFs)
- for _, uglyUrls := range []bool{true, false} {
+ for _, uglyURLs := range []bool{true, false} {
for _, relative := range []bool{true, false} {
- doTestCrossrefs(t, relative, uglyUrls)
+ doTestCrossrefs(t, relative, uglyURLs)
}
}
}
-func doTestCrossrefs(t *testing.T, relative, uglyUrls bool) {
+func doTestCrossrefs(t *testing.T, relative, uglyURLs bool) {
viper.Reset()
defer viper.Reset()
- baseUrl := "http://foo/bar"
+ baseURL := "http://foo/bar"
viper.Set("DefaultExtension", "html")
- viper.Set("baseurl", baseUrl)
- viper.Set("UglyURLs", uglyUrls)
+ viper.Set("baseurl", baseURL)
+ viper.Set("UglyURLs", uglyURLs)
viper.Set("verbose", true)
var refShortcode string
var expectedBase string
- var expectedUrlSuffix string
+ var expectedURLSuffix string
var expectedPathSuffix string
if relative {
expectedBase = "/bar"
} else {
refShortcode = "ref"
- expectedBase = baseUrl
+ expectedBase = baseURL
}
- if uglyUrls {
- expectedUrlSuffix = ".html"
+ if uglyURLs {
+ expectedURLSuffix = ".html"
expectedPathSuffix = ".html"
} else {
- expectedUrlSuffix = "/"
+ expectedURLSuffix = "/"
expectedPathSuffix = "/index.html"
}
s := &Site{
Source: &source.InMemorySource{ByteSource: sources},
- Targets: targetList{Page: &target.PagePub{UglyURLs: uglyUrls}},
+ Targets: targetList{Page: &target.PagePub{UglyURLs: uglyURLs}},
}
s.initializeSiteInfo()
doc string
expected string
}{
- {filepath.FromSlash(fmt.Sprintf("sect/doc1%s", expectedPathSuffix)), fmt.Sprintf("<p>Ref 2: %s/sect/doc2%s</p>\n", expectedBase, expectedUrlSuffix)},
- {filepath.FromSlash(fmt.Sprintf("sect/doc2%s", expectedPathSuffix)), fmt.Sprintf("<p><strong>Ref 1:</strong></p>\n\n%s/sect/doc1%s\n\n<p>THE END.</p>\n", expectedBase, expectedUrlSuffix)},
+ {filepath.FromSlash(fmt.Sprintf("sect/doc1%s", expectedPathSuffix)), fmt.Sprintf("<p>Ref 2: %s/sect/doc2%s</p>\n", expectedBase, expectedURLSuffix)},
+ {filepath.FromSlash(fmt.Sprintf("sect/doc2%s", expectedPathSuffix)), fmt.Sprintf("<p><strong>Ref 1:</strong></p>\n\n%s/sect/doc1%s\n\n<p>THE END.</p>\n", expectedBase, expectedURLSuffix)},
}
for _, test := range tests {
}
// Issue #939
-func Test404ShouldAlwaysHaveUglyUrls(t *testing.T) {
+func Test404ShouldAlwaysHaveUglyURLs(t *testing.T) {
hugofs.DestinationFS = new(afero.MemMapFs)
for _, uglyURLs := range []bool{true, false} {
- doTest404ShouldAlwaysHaveUglyUrls(t, uglyURLs)
+ doTest404ShouldAlwaysHaveUglyURLs(t, uglyURLs)
}
}
-func doTest404ShouldAlwaysHaveUglyUrls(t *testing.T, uglyURLs bool) {
+func doTest404ShouldAlwaysHaveUglyURLs(t *testing.T, uglyURLs bool) {
viper.Reset()
defer viper.Reset()
}
}
-func TestAbsUrlify(t *testing.T) {
+func TestAbsURLify(t *testing.T) {
viper.Reset()
defer viper.Reset()
}
if content != expected {
- t.Errorf("AbsUrlify content expected:\n%q\ngot\n%q", expected, content)
+ t.Errorf("AbsURLify content expected:\n%q\ngot\n%q", expected, content)
}
}
}