hugolib: Camelcase ALL_CAPS vars and const in tests

See #2014
This commit is contained in:
Bjørn Erik Pedersen 2016-04-07 16:10:41 +02:00
parent 05b888877d
commit 3950b1375c
4 changed files with 45 additions and 45 deletions

View file

@ -39,7 +39,7 @@ func TestRobotsTXTOutput(t *testing.T) {
viper.Set("enableRobotsTXT", true)
s := &Site{
Source: &source.InMemorySource{ByteSource: WEIGHTED_SOURCES},
Source: &source.InMemorySource{ByteSource: weightedSources},
}
s.initializeSiteInfo()

View file

@ -54,7 +54,7 @@ func TestRSSOutput(t *testing.T) {
hugofs.InitMemFs()
s := &Site{
Source: &source.InMemorySource{ByteSource: WEIGHTED_SOURCES},
Source: &source.InMemorySource{ByteSource: weightedSources},
}
s.initializeSiteInfo()
s.prepTemplates("rss.xml", rssTemplate)

View file

@ -34,19 +34,19 @@ import (
)
const (
TEMPLATE_TITLE = "{{ .Title }}"
PAGE_SIMPLE_TITLE = `---
templateTitle = "{{ .Title }}"
pageSimpleTitle = `---
title: simple template
---
content`
TEMPLATE_MISSING_FUNC = "{{ .Title | funcdoesnotexists }}"
TEMPLATE_FUNC = "{{ .Title | urlize }}"
TEMPLATE_CONTENT = "{{ .Content }}"
TEMPLATE_DATE = "{{ .Date }}"
TEMPLATE_WITH_URL_ABS = "<a href=\"/foobar.jpg\">Going</a>"
templateMissingFunc = "{{ .Title | funcdoesnotexists }}"
templateFunc = "{{ .Title | urlize }}"
templateContent = "{{ .Content }}"
templateDate = "{{ .Date }}"
templateWithURLAbs = "<a href=\"/foobar.jpg\">Going</a>"
PAGE_WITH_MD = `---
pageWithMd = `---
title: page with md
---
# heading 1
@ -113,7 +113,7 @@ func pageMust(p *Page, err error) *Page {
}
func TestDegenerateRenderThingMissingTemplate(t *testing.T) {
p, _ := NewPageFrom(strings.NewReader(PAGE_SIMPLE_TITLE), "content/a/file.md")
p, _ := NewPageFrom(strings.NewReader(pageSimpleTitle), "content/a/file.md")
p.Convert()
s := new(Site)
s.prepTemplates()
@ -125,7 +125,7 @@ func TestDegenerateRenderThingMissingTemplate(t *testing.T) {
func TestAddInvalidTemplate(t *testing.T) {
s := new(Site)
err := s.prepTemplates("missing", TEMPLATE_MISSING_FUNC)
err := s.prepTemplates("missing", templateMissingFunc)
if err == nil {
t.Fatalf("Expecting the template to return an error")
}
@ -147,10 +147,10 @@ func TestRenderThing(t *testing.T) {
template string
expected string
}{
{PAGE_SIMPLE_TITLE, TEMPLATE_TITLE, "simple template"},
{PAGE_SIMPLE_TITLE, TEMPLATE_FUNC, "simple-template"},
{PAGE_WITH_MD, TEMPLATE_CONTENT, "\n\n<h1 id=\"heading-1:91b5c4a22fc6103c73bb91e4a40568f8\">heading 1</h1>\n\n<p>text</p>\n\n<h2 id=\"heading-2:91b5c4a22fc6103c73bb91e4a40568f8\">heading 2</h2>\n\n<p>more text</p>\n"},
{simplePageRFC3339Date, TEMPLATE_DATE, "2013-05-17 16:59:30 &#43;0000 UTC"},
{pageSimpleTitle, templateTitle, "simple template"},
{pageSimpleTitle, templateFunc, "simple-template"},
{pageWithMd, templateContent, "\n\n<h1 id=\"heading-1:91b5c4a22fc6103c73bb91e4a40568f8\">heading 1</h1>\n\n<p>text</p>\n\n<h2 id=\"heading-2:91b5c4a22fc6103c73bb91e4a40568f8\">heading 2</h2>\n\n<p>more text</p>\n"},
{simplePageRFC3339Date, templateDate, "2013-05-17 16:59:30 &#43;0000 UTC"},
}
for i, test := range tests {
@ -193,10 +193,10 @@ func TestRenderThingOrDefault(t *testing.T) {
template string
expected string
}{
{true, TEMPLATE_TITLE, HTML("simple template")},
{true, TEMPLATE_FUNC, HTML("simple-template")},
{false, TEMPLATE_TITLE, HTML("simple template")},
{false, TEMPLATE_FUNC, HTML("simple-template")},
{true, templateTitle, HTML("simple template")},
{true, templateFunc, HTML("simple-template")},
{false, templateTitle, HTML("simple template")},
{false, templateFunc, HTML("simple-template")},
}
hugofs.InitMemFs()
@ -205,7 +205,7 @@ func TestRenderThingOrDefault(t *testing.T) {
s := &Site{}
p, err := NewPageFrom(strings.NewReader(PAGE_SIMPLE_TITLE), "content/a/file.md")
p, err := NewPageFrom(strings.NewReader(pageSimpleTitle), "content/a/file.md")
if err != nil {
t.Fatalf("Error parsing buffer: %s", err)
}
@ -638,7 +638,7 @@ func TestAbsURLify(t *testing.T) {
t.Logf("Rendering with BaseURL %q and CanonifyURLs set %v", viper.GetString("baseURL"), canonify)
s.initializeSiteInfo()
s.prepTemplates("blue/single.html", TEMPLATE_WITH_URL_ABS)
s.prepTemplates("blue/single.html", templateWithURLAbs)
if err := s.CreatePages(); err != nil {
t.Fatalf("Unable to create pages: %s", err)
@ -681,7 +681,7 @@ func TestAbsURLify(t *testing.T) {
}
}
var WEIGHTED_PAGE_1 = []byte(`+++
var weightedPage1 = []byte(`+++
weight = "2"
title = "One"
my_param = "foo"
@ -689,7 +689,7 @@ my_date = 1979-05-27T07:32:00Z
+++
Front Matter with Ordered Pages`)
var WEIGHTED_PAGE_2 = []byte(`+++
var weightedPage2 = []byte(`+++
weight = "6"
title = "Two"
publishdate = "2012-03-05"
@ -697,7 +697,7 @@ my_param = "foo"
+++
Front Matter with Ordered Pages 2`)
var WEIGHTED_PAGE_3 = []byte(`+++
var weightedPage3 = []byte(`+++
weight = "4"
title = "Three"
date = "2012-04-06"
@ -708,7 +708,7 @@ my_date = 2010-05-27T07:32:00Z
+++
Front Matter with Ordered Pages 3`)
var WEIGHTED_PAGE_4 = []byte(`+++
var weightedPage4 = []byte(`+++
weight = "4"
title = "Four"
date = "2012-01-01"
@ -718,11 +718,11 @@ my_date = 2010-05-27T07:32:00Z
+++
Front Matter with Ordered Pages 4. This is longer content`)
var WEIGHTED_SOURCES = []source.ByteSource{
{filepath.FromSlash("sect/doc1.md"), WEIGHTED_PAGE_1},
{filepath.FromSlash("sect/doc2.md"), WEIGHTED_PAGE_2},
{filepath.FromSlash("sect/doc3.md"), WEIGHTED_PAGE_3},
{filepath.FromSlash("sect/doc4.md"), WEIGHTED_PAGE_4},
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},
}
func TestOrderedPages(t *testing.T) {
@ -733,7 +733,7 @@ func TestOrderedPages(t *testing.T) {
viper.Set("baseurl", "http://auth/bub")
s := &Site{
Source: &source.InMemorySource{ByteSource: WEIGHTED_SOURCES},
Source: &source.InMemorySource{ByteSource: weightedSources},
}
s.initializeSiteInfo()
@ -786,11 +786,11 @@ func TestOrderedPages(t *testing.T) {
}
}
var GROUPED_SOURCES = []source.ByteSource{
{filepath.FromSlash("sect1/doc1.md"), WEIGHTED_PAGE_1},
{filepath.FromSlash("sect1/doc2.md"), WEIGHTED_PAGE_2},
{filepath.FromSlash("sect2/doc3.md"), WEIGHTED_PAGE_3},
{filepath.FromSlash("sect3/doc4.md"), WEIGHTED_PAGE_4},
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},
}
func TestGroupedPages(t *testing.T) {
@ -807,7 +807,7 @@ func TestGroupedPages(t *testing.T) {
viper.Set("baseurl", "http://auth/bub")
s := &Site{
Source: &source.InMemorySource{ByteSource: GROUPED_SOURCES},
Source: &source.InMemorySource{ByteSource: groupedSources},
}
s.initializeSiteInfo()
@ -950,7 +950,7 @@ func TestGroupedPages(t *testing.T) {
}
}
var PAGE_WITH_WEIGHTED_TAXONOMIES_2 = []byte(`+++
var pageWithWeightedTaxonomies1 = []byte(`+++
tags = [ "a", "b", "c" ]
tags_weight = 22
categories = ["d"]
@ -959,7 +959,7 @@ categories_weight = 44
+++
Front Matter with weighted tags and categories`)
var PAGE_WITH_WEIGHTED_TAXONOMIES_1 = []byte(`+++
var pageWithWeightedTaxonomies2 = []byte(`+++
tags = "a"
tags_weight = 33
title = "bar"
@ -970,7 +970,7 @@ date = 1979-05-27T07:32:00Z
+++
Front Matter with weighted tags and categories`)
var PAGE_WITH_WEIGHTED_TAXONOMIES_3 = []byte(`+++
var pageWithWeightedTaxonomies3 = []byte(`+++
title = "bza"
categories = [ "e" ]
categories_weight = 11
@ -985,9 +985,9 @@ func TestWeightedTaxonomies(t *testing.T) {
hugofs.InitMemFs()
sources := []source.ByteSource{
{filepath.FromSlash("sect/doc1.md"), PAGE_WITH_WEIGHTED_TAXONOMIES_1},
{filepath.FromSlash("sect/doc2.md"), PAGE_WITH_WEIGHTED_TAXONOMIES_2},
{filepath.FromSlash("sect/doc3.md"), PAGE_WITH_WEIGHTED_TAXONOMIES_3},
{filepath.FromSlash("sect/doc1.md"), pageWithWeightedTaxonomies2},
{filepath.FromSlash("sect/doc2.md"), pageWithWeightedTaxonomies1},
{filepath.FromSlash("sect/doc3.md"), pageWithWeightedTaxonomies3},
}
taxonomies := make(map[string]string)

View file

@ -44,7 +44,7 @@ func TestSitemapOutput(t *testing.T) {
viper.Set("baseurl", "http://auth/bub/")
s := &Site{
Source: &source.InMemorySource{ByteSource: WEIGHTED_SOURCES},
Source: &source.InMemorySource{ByteSource: weightedSources},
}
s.initializeSiteInfo()