mirror of
https://github.com/gohugoio/hugo.git
synced 2025-03-22 10:51:50 +00:00
hugolib: Fix some more Golint warnings
This commit is contained in:
parent
8a60571fd2
commit
937592cb85
4 changed files with 13 additions and 12 deletions
|
@ -18,13 +18,13 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
var PAGE_YAML_WITH_TAXONOMIES_A = `---
|
var pageYamlWithTaxonomiesA = `---
|
||||||
tags: ['a', 'B', 'c']
|
tags: ['a', 'B', 'c']
|
||||||
categories: 'd'
|
categories: 'd'
|
||||||
---
|
---
|
||||||
YAML frontmatter with tags and categories taxonomy.`
|
YAML frontmatter with tags and categories taxonomy.`
|
||||||
|
|
||||||
var PAGE_YAML_WITH_TAXONOMIES_B = `---
|
var pageYamlWithTaxonomiesB = `---
|
||||||
tags:
|
tags:
|
||||||
- "a"
|
- "a"
|
||||||
- "B"
|
- "B"
|
||||||
|
@ -33,13 +33,13 @@ categories: 'd'
|
||||||
---
|
---
|
||||||
YAML frontmatter with tags and categories taxonomy.`
|
YAML frontmatter with tags and categories taxonomy.`
|
||||||
|
|
||||||
var PAGE_YAML_WITH_TAXONOMIES_C = `---
|
var pageYamlWithTaxonomiesC = `---
|
||||||
tags: 'E'
|
tags: 'E'
|
||||||
categories: 'd'
|
categories: 'd'
|
||||||
---
|
---
|
||||||
YAML frontmatter with tags and categories taxonomy.`
|
YAML frontmatter with tags and categories taxonomy.`
|
||||||
|
|
||||||
var PAGE_JSON_WITH_TAXONOMIES = `{
|
var pageJSONWithTaxonomies = `{
|
||||||
"categories": "D",
|
"categories": "D",
|
||||||
"tags": [
|
"tags": [
|
||||||
"a",
|
"a",
|
||||||
|
@ -49,18 +49,18 @@ var PAGE_JSON_WITH_TAXONOMIES = `{
|
||||||
}
|
}
|
||||||
JSON Front Matter with tags and categories`
|
JSON Front Matter with tags and categories`
|
||||||
|
|
||||||
var PAGE_TOML_WITH_TAXONOMIES = `+++
|
var pageTomlWithTaxonomies = `+++
|
||||||
tags = [ "a", "B", "c" ]
|
tags = [ "a", "B", "c" ]
|
||||||
categories = "d"
|
categories = "d"
|
||||||
+++
|
+++
|
||||||
TOML Front Matter with tags and categories`
|
TOML Front Matter with tags and categories`
|
||||||
|
|
||||||
func TestParseTaxonomies(t *testing.T) {
|
func TestParseTaxonomies(t *testing.T) {
|
||||||
for _, test := range []string{PAGE_TOML_WITH_TAXONOMIES,
|
for _, test := range []string{pageTomlWithTaxonomies,
|
||||||
PAGE_JSON_WITH_TAXONOMIES,
|
pageJSONWithTaxonomies,
|
||||||
PAGE_YAML_WITH_TAXONOMIES_A,
|
pageYamlWithTaxonomiesA,
|
||||||
PAGE_YAML_WITH_TAXONOMIES_B,
|
pageYamlWithTaxonomiesB,
|
||||||
PAGE_YAML_WITH_TAXONOMIES_C,
|
pageYamlWithTaxonomiesC,
|
||||||
} {
|
} {
|
||||||
|
|
||||||
p, _ := NewPage("page/with/taxonomy")
|
p, _ := NewPage("page/with/taxonomy")
|
||||||
|
|
|
@ -534,7 +534,7 @@ func BenchmarkReplaceShortcodeTokens(b *testing.B) {
|
||||||
{strings.Repeat("A ", 3000) + " {#{#HUGOSHORTCODE-1#}#}." + strings.Repeat("BC ", 1000) + " {#{#HUGOSHORTCODE-1#}#}.", map[string]string{"{#{#HUGOSHORTCODE-1#}#}": "Hello World"}, []byte(strings.Repeat("A ", 3000) + " Hello World." + strings.Repeat("BC ", 1000) + " Hello World.")},
|
{strings.Repeat("A ", 3000) + " {#{#HUGOSHORTCODE-1#}#}." + strings.Repeat("BC ", 1000) + " {#{#HUGOSHORTCODE-1#}#}.", map[string]string{"{#{#HUGOSHORTCODE-1#}#}": "Hello World"}, []byte(strings.Repeat("A ", 3000) + " Hello World." + strings.Repeat("BC ", 1000) + " Hello World.")},
|
||||||
}
|
}
|
||||||
|
|
||||||
var in []input = make([]input, b.N*len(data))
|
var in = make([]input, b.N*len(data))
|
||||||
var cnt = 0
|
var cnt = 0
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
for _, this := range data {
|
for _, this := range data {
|
||||||
|
|
|
@ -18,6 +18,7 @@ import (
|
||||||
jww "github.com/spf13/jwalterweatherman"
|
jww "github.com/spf13/jwalterweatherman"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Sitemap configures the sitemap to be generated.
|
||||||
type Sitemap struct {
|
type Sitemap struct {
|
||||||
ChangeFreq string
|
ChangeFreq string
|
||||||
Priority float64
|
Priority float64
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
|
|
||||||
func TestSitePossibleTaxonomies(t *testing.T) {
|
func TestSitePossibleTaxonomies(t *testing.T) {
|
||||||
site := new(Site)
|
site := new(Site)
|
||||||
page, _ := NewPageFrom(strings.NewReader(PAGE_YAML_WITH_TAXONOMIES_A), "path/to/page")
|
page, _ := NewPageFrom(strings.NewReader(pageYamlWithTaxonomiesA), "path/to/page")
|
||||||
site.Pages = append(site.Pages, page)
|
site.Pages = append(site.Pages, page)
|
||||||
taxonomies := site.possibleTaxonomies()
|
taxonomies := site.possibleTaxonomies()
|
||||||
if !compareStringSlice(taxonomies, []string{"tags", "categories"}) {
|
if !compareStringSlice(taxonomies, []string{"tags", "categories"}) {
|
||||||
|
|
Loading…
Reference in a new issue