mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-29 02:52:14 -05:00
hugolib: Use named keys in composite literals
Make `go vet` great again
This commit is contained in:
parent
c5d072990a
commit
715d4425ad
5 changed files with 107 additions and 100 deletions
|
@ -14,17 +14,18 @@
|
|||
package hugolib
|
||||
|
||||
import (
|
||||
"github.com/spf13/hugo/parser"
|
||||
"github.com/spf13/hugo/source"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/spf13/hugo/parser"
|
||||
"github.com/spf13/hugo/source"
|
||||
)
|
||||
|
||||
func TestDataDirJSON(t *testing.T) {
|
||||
sources := []source.ByteSource{
|
||||
{filepath.FromSlash("test/foo.json"), []byte(`{ "bar": "foofoo" }`)},
|
||||
{filepath.FromSlash("test.json"), []byte(`{ "hello": [ { "world": "foo" } ] }`)},
|
||||
{Name: filepath.FromSlash("test/foo.json"), Content: []byte(`{ "bar": "foofoo" }`)},
|
||||
{Name: filepath.FromSlash("test.json"), Content: []byte(`{ "hello": [ { "world": "foo" } ] }`)},
|
||||
}
|
||||
|
||||
expected, err := parser.HandleJSONMetaData([]byte(`{ "test": { "hello": [{ "world": "foo" }] , "foo": { "bar":"foofoo" } } }`))
|
||||
|
@ -38,7 +39,7 @@ func TestDataDirJSON(t *testing.T) {
|
|||
|
||||
func TestDataDirToml(t *testing.T) {
|
||||
sources := []source.ByteSource{
|
||||
{filepath.FromSlash("test/kung.toml"), []byte("[foo]\nbar = 1")},
|
||||
{Name: filepath.FromSlash("test/kung.toml"), Content: []byte("[foo]\nbar = 1")},
|
||||
}
|
||||
|
||||
expected, err := parser.HandleTOMLMetaData([]byte("[test]\n[test.kung]\n[test.kung.foo]\nbar = 1"))
|
||||
|
@ -53,10 +54,10 @@ func TestDataDirToml(t *testing.T) {
|
|||
func TestDataDirYAMLWithOverridenValue(t *testing.T) {
|
||||
sources := []source.ByteSource{
|
||||
// filepath.Walk walks the files in lexical order, '/' comes before '.'. Simulate this:
|
||||
{filepath.FromSlash("a.yaml"), []byte("a: 1")},
|
||||
{filepath.FromSlash("test/v1.yaml"), []byte("v1-2: 2")},
|
||||
{filepath.FromSlash("test/v2.yaml"), []byte("v2:\n- 2\n- 3")},
|
||||
{filepath.FromSlash("test.yaml"), []byte("v1: 1")},
|
||||
{Name: filepath.FromSlash("a.yaml"), Content: []byte("a: 1")},
|
||||
{Name: filepath.FromSlash("test/v1.yaml"), Content: []byte("v1-2: 2")},
|
||||
{Name: filepath.FromSlash("test/v2.yaml"), Content: []byte("v2:\n- 2\n- 3")},
|
||||
{Name: filepath.FromSlash("test.yaml"), Content: []byte("v1: 1")},
|
||||
}
|
||||
|
||||
expected := map[string]interface{}{"a": map[string]interface{}{"a": 1},
|
||||
|
@ -68,12 +69,12 @@ func TestDataDirYAMLWithOverridenValue(t *testing.T) {
|
|||
// issue 892
|
||||
func TestDataDirMultipleSources(t *testing.T) {
|
||||
s1 := []source.ByteSource{
|
||||
{filepath.FromSlash("test/first.toml"), []byte("bar = 1")},
|
||||
{Name: filepath.FromSlash("test/first.toml"), Content: []byte("bar = 1")},
|
||||
}
|
||||
|
||||
s2 := []source.ByteSource{
|
||||
{filepath.FromSlash("test/first.toml"), []byte("bar = 2")},
|
||||
{filepath.FromSlash("test/second.toml"), []byte("tender = 2")},
|
||||
{Name: filepath.FromSlash("test/first.toml"), Content: []byte("bar = 2")},
|
||||
{Name: filepath.FromSlash("test/second.toml"), Content: []byte("tender = 2")},
|
||||
}
|
||||
|
||||
expected, _ := parser.HandleTOMLMetaData([]byte("[test.first]\nbar = 1\n[test.second]\ntender=2"))
|
||||
|
@ -84,7 +85,7 @@ func TestDataDirMultipleSources(t *testing.T) {
|
|||
|
||||
func TestDataDirUnknownFormat(t *testing.T) {
|
||||
sources := []source.ByteSource{
|
||||
{filepath.FromSlash("test.roml"), []byte("boo")},
|
||||
{Name: filepath.FromSlash("test.roml"), Content: []byte("boo")},
|
||||
}
|
||||
s := &Site{}
|
||||
err := s.loadData([]source.Input{&source.InMemorySource{ByteSource: sources}})
|
||||
|
|
|
@ -30,15 +30,15 @@ func TestDefaultHandler(t *testing.T) {
|
|||
|
||||
hugofs.InitMemFs()
|
||||
sources := []source.ByteSource{
|
||||
{filepath.FromSlash("sect/doc1.html"), []byte("---\nmarkup: markdown\n---\n# title\nsome *content*")},
|
||||
{filepath.FromSlash("sect/doc2.html"), []byte("<!doctype html><html><body>more content</body></html>")},
|
||||
{filepath.FromSlash("sect/doc3.md"), []byte("# doc3\n*some* content")},
|
||||
{filepath.FromSlash("sect/doc4.md"), []byte("---\ntitle: doc4\n---\n# doc4\n*some content*")},
|
||||
{filepath.FromSlash("sect/doc3/img1.png"), []byte("‰PNG <20><><EFBFBD> IHDR<44><52><EFBFBD><01><><EFBFBD><08><><EFBFBD><EFBFBD>:~›U<E280BA><55><EFBFBD> IDATWcø<0F><01>ZMoñ<6F><C3B1><EFBFBD><EFBFBD>IEND®B`‚")},
|
||||
{filepath.FromSlash("sect/img2.gif"), []byte("GIF89a<01><01>€<EFBFBD><E282AC>ÿÿÿ<C3BF><C3BF><EFBFBD>,<2C><><EFBFBD><EFBFBD><01><01><>D<01>;")},
|
||||
{filepath.FromSlash("sect/img2.spf"), []byte("****FAKE-FILETYPE****")},
|
||||
{filepath.FromSlash("doc7.html"), []byte("<html><body>doc7 content</body></html>")},
|
||||
{filepath.FromSlash("sect/doc8.html"), []byte("---\nmarkup: md\n---\n# title\nsome *content*")},
|
||||
{Name: filepath.FromSlash("sect/doc1.html"), Content: []byte("---\nmarkup: markdown\n---\n# title\nsome *content*")},
|
||||
{Name: filepath.FromSlash("sect/doc2.html"), Content: []byte("<!doctype html><html><body>more content</body></html>")},
|
||||
{Name: filepath.FromSlash("sect/doc3.md"), Content: []byte("# doc3\n*some* content")},
|
||||
{Name: filepath.FromSlash("sect/doc4.md"), Content: []byte("---\ntitle: doc4\n---\n# doc4\n*some content*")},
|
||||
{Name: filepath.FromSlash("sect/doc3/img1.png"), Content: []byte("‰PNG <20><><EFBFBD> IHDR<44><52><EFBFBD><01><><EFBFBD><08><><EFBFBD><EFBFBD>:~›U<E280BA><55><EFBFBD> IDATWcø<0F><01>ZMoñ<6F><C3B1><EFBFBD><EFBFBD>IEND®B`‚")},
|
||||
{Name: filepath.FromSlash("sect/img2.gif"), Content: []byte("GIF89a<01><01>€<EFBFBD><E282AC>ÿÿÿ<C3BF><C3BF><EFBFBD>,<2C><><EFBFBD><EFBFBD><01><01><>D<01>;")},
|
||||
{Name: filepath.FromSlash("sect/img2.spf"), Content: []byte("****FAKE-FILETYPE****")},
|
||||
{Name: filepath.FromSlash("doc7.html"), Content: []byte("<html><body>doc7 content</body></html>")},
|
||||
{Name: filepath.FromSlash("sect/doc8.html"), Content: []byte("---\nmarkup: md\n---\n# title\nsome *content*")},
|
||||
}
|
||||
|
||||
viper.Set("DefaultExtension", "html")
|
||||
|
|
|
@ -122,16 +122,16 @@ weight = 4
|
|||
Front Matter with Menu Pages`)
|
||||
|
||||
var menuPageSources = []source.ByteSource{
|
||||
{filepath.FromSlash("sect/doc1.md"), menuPage1},
|
||||
{filepath.FromSlash("sect/doc2.md"), menuPage2},
|
||||
{filepath.FromSlash("sect/doc3.md"), menuPage3},
|
||||
{Name: filepath.FromSlash("sect/doc1.md"), Content: menuPage1},
|
||||
{Name: filepath.FromSlash("sect/doc2.md"), Content: menuPage2},
|
||||
{Name: filepath.FromSlash("sect/doc3.md"), Content: menuPage3},
|
||||
}
|
||||
|
||||
var menuPageSectionsSources = []source.ByteSource{
|
||||
{filepath.FromSlash("first/doc1.md"), menuPage1},
|
||||
{filepath.FromSlash("first/doc2.md"), menuPage2},
|
||||
{filepath.FromSlash("second-section/doc3.md"), menuPage3},
|
||||
{filepath.FromSlash("Fish and Chips/doc4.md"), menuPage4},
|
||||
{Name: filepath.FromSlash("first/doc1.md"), Content: menuPage1},
|
||||
{Name: filepath.FromSlash("first/doc2.md"), Content: menuPage2},
|
||||
{Name: filepath.FromSlash("second-section/doc3.md"), Content: menuPage3},
|
||||
{Name: filepath.FromSlash("Fish and Chips/doc4.md"), Content: menuPage4},
|
||||
}
|
||||
|
||||
func tstCreateMenuPageWithNameTOML(title, menu, name string) []byte {
|
||||
|
@ -184,15 +184,15 @@ Front Matter with Menu with Identifier`, title, menu, identifier))
|
|||
func TestPageMenuWithIdentifier(t *testing.T) {
|
||||
|
||||
toml := []source.ByteSource{
|
||||
{"sect/doc1.md", tstCreateMenuPageWithIdentifierTOML("t1", "m1", "i1")},
|
||||
{"sect/doc2.md", tstCreateMenuPageWithIdentifierTOML("t1", "m1", "i2")},
|
||||
{"sect/doc3.md", tstCreateMenuPageWithIdentifierTOML("t1", "m1", "i2")}, // duplicate
|
||||
{Name: "sect/doc1.md", Content: tstCreateMenuPageWithIdentifierTOML("t1", "m1", "i1")},
|
||||
{Name: "sect/doc2.md", Content: tstCreateMenuPageWithIdentifierTOML("t1", "m1", "i2")},
|
||||
{Name: "sect/doc3.md", Content: tstCreateMenuPageWithIdentifierTOML("t1", "m1", "i2")}, // duplicate
|
||||
}
|
||||
|
||||
yaml := []source.ByteSource{
|
||||
{"sect/doc1.md", tstCreateMenuPageWithIdentifierYAML("t1", "m1", "i1")},
|
||||
{"sect/doc2.md", tstCreateMenuPageWithIdentifierYAML("t1", "m1", "i2")},
|
||||
{"sect/doc3.md", tstCreateMenuPageWithIdentifierYAML("t1", "m1", "i2")}, // duplicate
|
||||
{Name: "sect/doc1.md", Content: tstCreateMenuPageWithIdentifierYAML("t1", "m1", "i1")},
|
||||
{Name: "sect/doc2.md", Content: tstCreateMenuPageWithIdentifierYAML("t1", "m1", "i2")},
|
||||
{Name: "sect/doc3.md", Content: tstCreateMenuPageWithIdentifierYAML("t1", "m1", "i2")}, // duplicate
|
||||
}
|
||||
|
||||
doTestPageMenuWithIdentifier(t, toml)
|
||||
|
@ -224,15 +224,15 @@ func doTestPageMenuWithIdentifier(t *testing.T, menuPageSources []source.ByteSou
|
|||
func TestPageMenuWithDuplicateName(t *testing.T) {
|
||||
|
||||
toml := []source.ByteSource{
|
||||
{"sect/doc1.md", tstCreateMenuPageWithNameTOML("t1", "m1", "n1")},
|
||||
{"sect/doc2.md", tstCreateMenuPageWithNameTOML("t1", "m1", "n2")},
|
||||
{"sect/doc3.md", tstCreateMenuPageWithNameTOML("t1", "m1", "n2")}, // duplicate
|
||||
{Name: "sect/doc1.md", Content: tstCreateMenuPageWithNameTOML("t1", "m1", "n1")},
|
||||
{Name: "sect/doc2.md", Content: tstCreateMenuPageWithNameTOML("t1", "m1", "n2")},
|
||||
{Name: "sect/doc3.md", Content: tstCreateMenuPageWithNameTOML("t1", "m1", "n2")}, // duplicate
|
||||
}
|
||||
|
||||
yaml := []source.ByteSource{
|
||||
{"sect/doc1.md", tstCreateMenuPageWithNameYAML("t1", "m1", "n1")},
|
||||
{"sect/doc2.md", tstCreateMenuPageWithNameYAML("t1", "m1", "n2")},
|
||||
{"sect/doc3.md", tstCreateMenuPageWithNameYAML("t1", "m1", "n2")}, // duplicate
|
||||
{Name: "sect/doc1.md", Content: tstCreateMenuPageWithNameYAML("t1", "m1", "n1")},
|
||||
{Name: "sect/doc2.md", Content: tstCreateMenuPageWithNameYAML("t1", "m1", "n2")},
|
||||
{Name: "sect/doc3.md", Content: tstCreateMenuPageWithNameYAML("t1", "m1", "n2")}, // duplicate
|
||||
}
|
||||
|
||||
doTestPageMenuWithDuplicateName(t, toml)
|
||||
|
@ -358,8 +358,8 @@ menu:
|
|||
Yaml Front Matter with Menu Pages`)
|
||||
|
||||
s := setupMenuTests(t, []source.ByteSource{
|
||||
{filepath.FromSlash("sect/yaml1.md"), ps1},
|
||||
{filepath.FromSlash("sect/yaml2.md"), ps2}})
|
||||
{Name: filepath.FromSlash("sect/yaml1.md"), Content: ps1},
|
||||
{Name: filepath.FromSlash("sect/yaml2.md"), Content: ps2}})
|
||||
|
||||
p1 := s.Pages[0]
|
||||
assert.Len(t, p1.Menus(), 2, "List YAML")
|
||||
|
|
|
@ -241,10 +241,10 @@ func TestDraftAndFutureRender(t *testing.T) {
|
|||
|
||||
hugofs.InitMemFs()
|
||||
sources := []source.ByteSource{
|
||||
{filepath.FromSlash("sect/doc1.md"), []byte("---\ntitle: doc1\ndraft: true\npublishdate: \"2414-05-29\"\n---\n# doc1\n*some content*")},
|
||||
{filepath.FromSlash("sect/doc2.md"), []byte("---\ntitle: doc2\ndraft: true\npublishdate: \"2012-05-29\"\n---\n# doc2\n*some content*")},
|
||||
{filepath.FromSlash("sect/doc3.md"), []byte("---\ntitle: doc3\ndraft: false\npublishdate: \"2414-05-29\"\n---\n# doc3\n*some content*")},
|
||||
{filepath.FromSlash("sect/doc4.md"), []byte("---\ntitle: doc4\ndraft: false\npublishdate: \"2012-05-29\"\n---\n# doc4\n*some content*")},
|
||||
{Name: filepath.FromSlash("sect/doc1.md"), Content: []byte("---\ntitle: doc1\ndraft: true\npublishdate: \"2414-05-29\"\n---\n# doc1\n*some content*")},
|
||||
{Name: filepath.FromSlash("sect/doc2.md"), Content: []byte("---\ntitle: doc2\ndraft: true\npublishdate: \"2012-05-29\"\n---\n# doc2\n*some content*")},
|
||||
{Name: filepath.FromSlash("sect/doc3.md"), Content: []byte("---\ntitle: doc3\ndraft: false\npublishdate: \"2414-05-29\"\n---\n# doc3\n*some content*")},
|
||||
{Name: filepath.FromSlash("sect/doc4.md"), Content: []byte("---\ntitle: doc4\ndraft: false\npublishdate: \"2012-05-29\"\n---\n# doc4\n*some content*")},
|
||||
}
|
||||
|
||||
siteSetup := func() *Site {
|
||||
|
@ -302,8 +302,8 @@ func TestFutureExpirationRender(t *testing.T) {
|
|||
|
||||
hugofs.InitMemFs()
|
||||
sources := []source.ByteSource{
|
||||
{filepath.FromSlash("sect/doc3.md"), []byte("---\ntitle: doc1\nexpirydate: \"2400-05-29\"\n---\n# doc1\n*some content*")},
|
||||
{filepath.FromSlash("sect/doc4.md"), []byte("---\ntitle: doc2\nexpirydate: \"2000-05-29\"\n---\n# doc2\n*some content*")},
|
||||
{Name: filepath.FromSlash("sect/doc3.md"), Content: []byte("---\ntitle: doc1\nexpirydate: \"2400-05-29\"\n---\n# doc1\n*some content*")},
|
||||
{Name: filepath.FromSlash("sect/doc4.md"), Content: []byte("---\ntitle: doc2\nexpirydate: \"2000-05-29\"\n---\n# doc2\n*some content*")},
|
||||
}
|
||||
|
||||
siteSetup := func() *Site {
|
||||
|
@ -380,18 +380,24 @@ func doTestCrossrefs(t *testing.T, relative, uglyURLs bool) {
|
|||
}
|
||||
|
||||
sources := []source.ByteSource{
|
||||
{filepath.FromSlash("sect/doc1.md"),
|
||||
[]byte(fmt.Sprintf(`Ref 2: {{< %s "sect/doc2.md" >}}`, refShortcode))},
|
||||
{
|
||||
Name: filepath.FromSlash("sect/doc1.md"),
|
||||
Content: []byte(fmt.Sprintf(`Ref 2: {{< %s "sect/doc2.md" >}}`, refShortcode)),
|
||||
},
|
||||
// Issue #1148: Make sure that no P-tags is added around shortcodes.
|
||||
{filepath.FromSlash("sect/doc2.md"),
|
||||
[]byte(fmt.Sprintf(`**Ref 1:**
|
||||
{
|
||||
Name: filepath.FromSlash("sect/doc2.md"),
|
||||
Content: []byte(fmt.Sprintf(`**Ref 1:**
|
||||
|
||||
{{< %s "sect/doc1.md" >}}
|
||||
|
||||
THE END.`, refShortcode))},
|
||||
THE END.`, refShortcode)),
|
||||
},
|
||||
// Issue #1753: Should not add a trailing newline after shortcode.
|
||||
{filepath.FromSlash("sect/doc3.md"),
|
||||
[]byte(fmt.Sprintf(`**Ref 1:**{{< %s "sect/doc3.md" >}}.`, refShortcode))},
|
||||
{
|
||||
Name: filepath.FromSlash("sect/doc3.md"),
|
||||
Content: []byte(fmt.Sprintf(`**Ref 1:**{{< %s "sect/doc3.md" >}}.`, refShortcode)),
|
||||
},
|
||||
}
|
||||
|
||||
s := &Site{
|
||||
|
@ -456,8 +462,8 @@ func doTestShouldAlwaysHaveUglyURLs(t *testing.T, uglyURLs bool) {
|
|||
viper.Set("UglyURLs", uglyURLs)
|
||||
|
||||
sources := []source.ByteSource{
|
||||
{filepath.FromSlash("sect/doc1.md"), []byte("---\nmarkup: markdown\n---\n# title\nsome *content*")},
|
||||
{filepath.FromSlash("sect/doc2.md"), []byte("---\nurl: /ugly.html\nmarkup: markdown\n---\n# title\ndoc2 *content*")},
|
||||
{Name: filepath.FromSlash("sect/doc1.md"), Content: []byte("---\nmarkup: markdown\n---\n# title\nsome *content*")},
|
||||
{Name: filepath.FromSlash("sect/doc2.md"), Content: []byte("---\nurl: /ugly.html\nmarkup: markdown\n---\n# title\ndoc2 *content*")},
|
||||
}
|
||||
|
||||
s := &Site{
|
||||
|
@ -548,9 +554,9 @@ func doTestSectionNaming(t *testing.T, canonify, uglify, pluralize bool) {
|
|||
}
|
||||
|
||||
sources := []source.ByteSource{
|
||||
{filepath.FromSlash("sect/doc1.html"), []byte("doc1")},
|
||||
{filepath.FromSlash("Fish and Chips/doc2.html"), []byte("doc2")},
|
||||
{filepath.FromSlash("ラーメン/doc3.html"), []byte("doc3")},
|
||||
{Name: filepath.FromSlash("sect/doc1.html"), Content: []byte("doc1")},
|
||||
{Name: filepath.FromSlash("Fish and Chips/doc2.html"), Content: []byte("doc2")},
|
||||
{Name: filepath.FromSlash("ラーメン/doc3.html"), Content: []byte("doc3")},
|
||||
}
|
||||
|
||||
s := &Site{
|
||||
|
@ -603,14 +609,14 @@ func TestSkipRender(t *testing.T) {
|
|||
|
||||
hugofs.InitMemFs()
|
||||
sources := []source.ByteSource{
|
||||
{filepath.FromSlash("sect/doc1.html"), []byte("---\nmarkup: markdown\n---\n# title\nsome *content*")},
|
||||
{filepath.FromSlash("sect/doc2.html"), []byte("<!doctype html><html><body>more content</body></html>")},
|
||||
{filepath.FromSlash("sect/doc3.md"), []byte("# doc3\n*some* content")},
|
||||
{filepath.FromSlash("sect/doc4.md"), []byte("---\ntitle: doc4\n---\n# doc4\n*some content*")},
|
||||
{filepath.FromSlash("sect/doc5.html"), []byte("<!doctype html><html>{{ template \"head\" }}<body>body5</body></html>")},
|
||||
{filepath.FromSlash("sect/doc6.html"), []byte("<!doctype html><html>{{ template \"head_abs\" }}<body>body5</body></html>")},
|
||||
{filepath.FromSlash("doc7.html"), []byte("<html><body>doc7 content</body></html>")},
|
||||
{filepath.FromSlash("sect/doc8.html"), []byte("---\nmarkup: md\n---\n# title\nsome *content*")},
|
||||
{Name: filepath.FromSlash("sect/doc1.html"), Content: []byte("---\nmarkup: markdown\n---\n# title\nsome *content*")},
|
||||
{Name: filepath.FromSlash("sect/doc2.html"), Content: []byte("<!doctype html><html><body>more content</body></html>")},
|
||||
{Name: filepath.FromSlash("sect/doc3.md"), Content: []byte("# doc3\n*some* content")},
|
||||
{Name: filepath.FromSlash("sect/doc4.md"), Content: []byte("---\ntitle: doc4\n---\n# doc4\n*some content*")},
|
||||
{Name: filepath.FromSlash("sect/doc5.html"), Content: []byte("<!doctype html><html>{{ template \"head\" }}<body>body5</body></html>")},
|
||||
{Name: filepath.FromSlash("sect/doc6.html"), Content: []byte("<!doctype html><html>{{ template \"head_abs\" }}<body>body5</body></html>")},
|
||||
{Name: filepath.FromSlash("doc7.html"), Content: []byte("<html><body>doc7 content</body></html>")},
|
||||
{Name: filepath.FromSlash("sect/doc8.html"), Content: []byte("---\nmarkup: md\n---\n# title\nsome *content*")},
|
||||
}
|
||||
|
||||
viper.Set("DefaultExtension", "html")
|
||||
|
@ -667,8 +673,8 @@ func TestAbsURLify(t *testing.T) {
|
|||
|
||||
hugofs.InitMemFs()
|
||||
sources := []source.ByteSource{
|
||||
{filepath.FromSlash("sect/doc1.html"), []byte("<!doctype html><html><head></head><body><a href=\"#frag1\">link</a></body></html>")},
|
||||
{filepath.FromSlash("content/blue/doc2.html"), []byte("---\nf: t\n---\n<!doctype html><html><body>more content</body></html>")},
|
||||
{Name: filepath.FromSlash("sect/doc1.html"), Content: []byte("<!doctype html><html><head></head><body><a href=\"#frag1\">link</a></body></html>")},
|
||||
{Name: filepath.FromSlash("content/blue/doc2.html"), Content: []byte("---\nf: t\n---\n<!doctype html><html><body>more content</body></html>")},
|
||||
}
|
||||
for _, baseURL := range []string{"http://auth/bub", "http://base", "//base"} {
|
||||
for _, canonify := range []bool{true, false} {
|
||||
|
@ -767,10 +773,10 @@ my_date = 2010-05-27T07:32:00Z
|
|||
Front Matter with Ordered Pages 4. This is longer content`)
|
||||
|
||||
var weightedSources = []source.ByteSource{
|
||||
{filepath.FromSlash("sect/doc1.md"), weightedPage1},
|
||||
{filepath.FromSlash("sect/doc2.md"), weightedPage2},
|
||||
{filepath.FromSlash("sect/doc3.md"), weightedPage3},
|
||||
{filepath.FromSlash("sect/doc4.md"), weightedPage4},
|
||||
{Name: filepath.FromSlash("sect/doc1.md"), Content: weightedPage1},
|
||||
{Name: filepath.FromSlash("sect/doc2.md"), Content: weightedPage2},
|
||||
{Name: filepath.FromSlash("sect/doc3.md"), Content: weightedPage3},
|
||||
{Name: filepath.FromSlash("sect/doc4.md"), Content: weightedPage4},
|
||||
}
|
||||
|
||||
func TestOrderedPages(t *testing.T) {
|
||||
|
@ -835,10 +841,10 @@ func TestOrderedPages(t *testing.T) {
|
|||
}
|
||||
|
||||
var groupedSources = []source.ByteSource{
|
||||
{filepath.FromSlash("sect1/doc1.md"), weightedPage1},
|
||||
{filepath.FromSlash("sect1/doc2.md"), weightedPage2},
|
||||
{filepath.FromSlash("sect2/doc3.md"), weightedPage3},
|
||||
{filepath.FromSlash("sect3/doc4.md"), weightedPage4},
|
||||
{Name: filepath.FromSlash("sect1/doc1.md"), Content: weightedPage1},
|
||||
{Name: filepath.FromSlash("sect1/doc2.md"), Content: weightedPage2},
|
||||
{Name: filepath.FromSlash("sect2/doc3.md"), Content: weightedPage3},
|
||||
{Name: filepath.FromSlash("sect3/doc4.md"), Content: weightedPage4},
|
||||
}
|
||||
|
||||
func TestGroupedPages(t *testing.T) {
|
||||
|
@ -1033,9 +1039,9 @@ func TestWeightedTaxonomies(t *testing.T) {
|
|||
|
||||
hugofs.InitMemFs()
|
||||
sources := []source.ByteSource{
|
||||
{filepath.FromSlash("sect/doc1.md"), pageWithWeightedTaxonomies2},
|
||||
{filepath.FromSlash("sect/doc2.md"), pageWithWeightedTaxonomies1},
|
||||
{filepath.FromSlash("sect/doc3.md"), pageWithWeightedTaxonomies3},
|
||||
{Name: filepath.FromSlash("sect/doc1.md"), Content: pageWithWeightedTaxonomies2},
|
||||
{Name: filepath.FromSlash("sect/doc2.md"), Content: pageWithWeightedTaxonomies1},
|
||||
{Name: filepath.FromSlash("sect/doc3.md"), Content: pageWithWeightedTaxonomies3},
|
||||
}
|
||||
taxonomies := make(map[string]string)
|
||||
|
||||
|
@ -1086,26 +1092,26 @@ func findPage(site *Site, f string) *Page {
|
|||
func setupLinkingMockSite(t *testing.T) *Site {
|
||||
hugofs.InitMemFs()
|
||||
sources := []source.ByteSource{
|
||||
{filepath.FromSlash("index.md"), []byte("")},
|
||||
{filepath.FromSlash("rootfile.md"), []byte("")},
|
||||
{filepath.FromSlash("root-image.png"), []byte("")},
|
||||
{Name: filepath.FromSlash("index.md"), Content: []byte("")},
|
||||
{Name: filepath.FromSlash("rootfile.md"), Content: []byte("")},
|
||||
{Name: filepath.FromSlash("root-image.png"), Content: []byte("")},
|
||||
|
||||
{filepath.FromSlash("level2/2-root.md"), []byte("")},
|
||||
{filepath.FromSlash("level2/index.md"), []byte("")},
|
||||
{filepath.FromSlash("level2/common.md"), []byte("")},
|
||||
{Name: filepath.FromSlash("level2/2-root.md"), Content: []byte("")},
|
||||
{Name: filepath.FromSlash("level2/index.md"), Content: []byte("")},
|
||||
{Name: filepath.FromSlash("level2/common.md"), Content: []byte("")},
|
||||
|
||||
// {filepath.FromSlash("level2b/2b-root.md"), []byte("")},
|
||||
// {filepath.FromSlash("level2b/index.md"), []byte("")},
|
||||
// {filepath.FromSlash("level2b/common.md"), []byte("")},
|
||||
// {Name: filepath.FromSlash("level2b/2b-root.md"), Content: []byte("")},
|
||||
// {Name: filepath.FromSlash("level2b/index.md"), Content: []byte("")},
|
||||
// {Name: filepath.FromSlash("level2b/common.md"), Content: []byte("")},
|
||||
|
||||
{filepath.FromSlash("level2/2-image.png"), []byte("")},
|
||||
{filepath.FromSlash("level2/common.png"), []byte("")},
|
||||
{Name: filepath.FromSlash("level2/2-image.png"), Content: []byte("")},
|
||||
{Name: filepath.FromSlash("level2/common.png"), Content: []byte("")},
|
||||
|
||||
{filepath.FromSlash("level2/level3/3-root.md"), []byte("")},
|
||||
{filepath.FromSlash("level2/level3/index.md"), []byte("")},
|
||||
{filepath.FromSlash("level2/level3/common.md"), []byte("")},
|
||||
{filepath.FromSlash("level2/level3/3-image.png"), []byte("")},
|
||||
{filepath.FromSlash("level2/level3/common.png"), []byte("")},
|
||||
{Name: filepath.FromSlash("level2/level3/3-root.md"), Content: []byte("")},
|
||||
{Name: filepath.FromSlash("level2/level3/index.md"), Content: []byte("")},
|
||||
{Name: filepath.FromSlash("level2/level3/common.md"), Content: []byte("")},
|
||||
{Name: filepath.FromSlash("level2/level3/3-image.png"), Content: []byte("")},
|
||||
{Name: filepath.FromSlash("level2/level3/common.png"), Content: []byte("")},
|
||||
}
|
||||
|
||||
viper.Set("baseurl", "http://auth/")
|
||||
|
|
|
@ -54,8 +54,8 @@ func (t *InMemoryAliasTarget) Publish(label string, permalink template.HTML) (er
|
|||
}
|
||||
|
||||
var urlFakeSource = []source.ByteSource{
|
||||
{filepath.FromSlash("content/blue/doc1.md"), []byte(slugDoc1)},
|
||||
{filepath.FromSlash("content/blue/doc2.md"), []byte(slugDoc2)},
|
||||
{Name: filepath.FromSlash("content/blue/doc1.md"), Content: []byte(slugDoc1)},
|
||||
{Name: filepath.FromSlash("content/blue/doc2.md"), Content: []byte(slugDoc2)},
|
||||
}
|
||||
|
||||
// Issue #1105
|
||||
|
|
Loading…
Reference in a new issue