mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
parent
d05b297e61
commit
29aa9baecd
2 changed files with 20 additions and 20 deletions
|
@ -279,26 +279,26 @@ func TestDraftAndFutureRender(t *testing.T) {
|
||||||
// Issue #957
|
// Issue #957
|
||||||
func TestCrossrefs(t *testing.T) {
|
func TestCrossrefs(t *testing.T) {
|
||||||
hugofs.DestinationFS = new(afero.MemMapFs)
|
hugofs.DestinationFS = new(afero.MemMapFs)
|
||||||
for _, uglyUrls := range []bool{true, false} {
|
for _, uglyURLs := range []bool{true, false} {
|
||||||
for _, relative := 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()
|
viper.Reset()
|
||||||
defer viper.Reset()
|
defer viper.Reset()
|
||||||
|
|
||||||
baseUrl := "http://foo/bar"
|
baseURL := "http://foo/bar"
|
||||||
viper.Set("DefaultExtension", "html")
|
viper.Set("DefaultExtension", "html")
|
||||||
viper.Set("baseurl", baseUrl)
|
viper.Set("baseurl", baseURL)
|
||||||
viper.Set("UglyURLs", uglyUrls)
|
viper.Set("UglyURLs", uglyURLs)
|
||||||
viper.Set("verbose", true)
|
viper.Set("verbose", true)
|
||||||
|
|
||||||
var refShortcode string
|
var refShortcode string
|
||||||
var expectedBase string
|
var expectedBase string
|
||||||
var expectedUrlSuffix string
|
var expectedURLSuffix string
|
||||||
var expectedPathSuffix string
|
var expectedPathSuffix string
|
||||||
|
|
||||||
if relative {
|
if relative {
|
||||||
|
@ -306,14 +306,14 @@ func doTestCrossrefs(t *testing.T, relative, uglyUrls bool) {
|
||||||
expectedBase = "/bar"
|
expectedBase = "/bar"
|
||||||
} else {
|
} else {
|
||||||
refShortcode = "ref"
|
refShortcode = "ref"
|
||||||
expectedBase = baseUrl
|
expectedBase = baseURL
|
||||||
}
|
}
|
||||||
|
|
||||||
if uglyUrls {
|
if uglyURLs {
|
||||||
expectedUrlSuffix = ".html"
|
expectedURLSuffix = ".html"
|
||||||
expectedPathSuffix = ".html"
|
expectedPathSuffix = ".html"
|
||||||
} else {
|
} else {
|
||||||
expectedUrlSuffix = "/"
|
expectedURLSuffix = "/"
|
||||||
expectedPathSuffix = "/index.html"
|
expectedPathSuffix = "/index.html"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,7 +331,7 @@ THE END.`, refShortcode))},
|
||||||
|
|
||||||
s := &Site{
|
s := &Site{
|
||||||
Source: &source.InMemorySource{ByteSource: sources},
|
Source: &source.InMemorySource{ByteSource: sources},
|
||||||
Targets: targetList{Page: &target.PagePub{UglyURLs: uglyUrls}},
|
Targets: targetList{Page: &target.PagePub{UglyURLs: uglyURLs}},
|
||||||
}
|
}
|
||||||
|
|
||||||
s.initializeSiteInfo()
|
s.initializeSiteInfo()
|
||||||
|
@ -345,8 +345,8 @@ THE END.`, refShortcode))},
|
||||||
doc string
|
doc string
|
||||||
expected 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/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/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 {
|
for _, test := range tests {
|
||||||
|
@ -366,14 +366,14 @@ THE END.`, refShortcode))},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Issue #939
|
// Issue #939
|
||||||
func Test404ShouldAlwaysHaveUglyUrls(t *testing.T) {
|
func Test404ShouldAlwaysHaveUglyURLs(t *testing.T) {
|
||||||
hugofs.DestinationFS = new(afero.MemMapFs)
|
hugofs.DestinationFS = new(afero.MemMapFs)
|
||||||
for _, uglyURLs := range []bool{true, false} {
|
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()
|
viper.Reset()
|
||||||
defer viper.Reset()
|
defer viper.Reset()
|
||||||
|
|
||||||
|
@ -590,7 +590,7 @@ func TestSkipRender(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAbsUrlify(t *testing.T) {
|
func TestAbsURLify(t *testing.T) {
|
||||||
viper.Reset()
|
viper.Reset()
|
||||||
defer viper.Reset()
|
defer viper.Reset()
|
||||||
|
|
||||||
|
@ -648,7 +648,7 @@ func TestAbsUrlify(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if content != expected {
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ func TestCutUsageMessage(t *testing.T) {
|
||||||
cutMessage string
|
cutMessage string
|
||||||
}{
|
}{
|
||||||
{"", ""},
|
{"", ""},
|
||||||
{" Usage of hugo: \n -b, --baseUrl=...", ""},
|
{" Usage of hugo: \n -b, --baseURL=...", ""},
|
||||||
{"Some error Usage of hugo: \n", "Some error"},
|
{"Some error Usage of hugo: \n", "Some error"},
|
||||||
{"Usage of hugo: \n -b --baseU", ""},
|
{"Usage of hugo: \n -b --baseU", ""},
|
||||||
{"CRITICAL error for usage of hugo ", "CRITICAL error for usage of hugo"},
|
{"CRITICAL error for usage of hugo ", "CRITICAL error for usage of hugo"},
|
||||||
|
|
Loading…
Reference in a new issue