shithub: hugo

Download patch

ref: 3950b1375c0be846c88d015d7ae20e45d51f97d2
parent: 05b888877db016e5c45711069272a39031377297
author: Bjørn Erik Pedersen <[email protected]>
date: Thu Apr 7 12:10:41 EDT 2016

hugolib: Camelcase ALL_CAPS vars and const in tests

See #2014

--- a/hugolib/robotstxt_test.go
+++ b/hugolib/robotstxt_test.go
@@ -39,7 +39,7 @@
 	viper.Set("enableRobotsTXT", true)
 
 	s := &Site{
-		Source: &source.InMemorySource{ByteSource: WEIGHTED_SOURCES},
+		Source: &source.InMemorySource{ByteSource: weightedSources},
 	}
 
 	s.initializeSiteInfo()
--- a/hugolib/rss_test.go
+++ b/hugolib/rss_test.go
@@ -54,7 +54,7 @@
 
 	hugofs.InitMemFs()
 	s := &Site{
-		Source: &source.InMemorySource{ByteSource: WEIGHTED_SOURCES},
+		Source: &source.InMemorySource{ByteSource: weightedSources},
 	}
 	s.initializeSiteInfo()
 	s.prepTemplates("rss.xml", rssTemplate)
--- a/hugolib/site_test.go
+++ b/hugolib/site_test.go
@@ -34,19 +34,19 @@
 )
 
 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 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 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 @@
 		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 @@
 		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 @@
 
 		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 @@
 		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 @@
 	}
 }
 
-var WEIGHTED_PAGE_1 = []byte(`+++
+var weightedPage1 = []byte(`+++
 weight = "2"
 title = "One"
 my_param = "foo"
@@ -689,7 +689,7 @@
 +++
 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 @@
 +++
 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 @@
 +++
 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 @@
 +++
 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 @@
 
 	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 @@
 	}
 }
 
-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 @@
 
 	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 @@
 	}
 }
 
-var PAGE_WITH_WEIGHTED_TAXONOMIES_2 = []byte(`+++
+var pageWithWeightedTaxonomies1 = []byte(`+++
 tags = [ "a", "b", "c" ]
 tags_weight = 22
 categories = ["d"]
@@ -959,7 +959,7 @@
 +++
 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 @@
 +++
 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 @@
 
 	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)
 
--- a/hugolib/sitemap_test.go
+++ b/hugolib/sitemap_test.go
@@ -44,7 +44,7 @@
 	viper.Set("baseurl", "http://auth/bub/")
 
 	s := &Site{
-		Source: &source.InMemorySource{ByteSource: WEIGHTED_SOURCES},
+		Source: &source.InMemorySource{ByteSource: weightedSources},
 	}
 
 	s.initializeSiteInfo()