Update test logs for uniformity and consistency
authorbep <bjorn.erik.pedersen@gmail.com>
Sun, 5 Apr 2015 19:03:16 +0000 (21:03 +0200)
committerspf13 <steve.francia@gmail.com>
Sat, 9 May 2015 02:27:00 +0000 (22:27 -0400)
Many minor fixes to make test logs more consistent and correct a
mispelling.

Standardize on "[%i] got X but expected Y" for log messages. Using
a consistent layout makes it easier to read the test results. This
was mostly changing "Got" to "got". Swapped the order of values on
several calls to bring them in line with the convention.

A few log messages had a sequence number added to identify the
exact scenario that failed. Otherwise, there would be no way to
ascertain which failed When there are many scenarios.

Correct spelling of "expected."

Fixes #1028
Merged be2097e1ad789eca5d893805a059d94defbe5c48

[close #1040]

helpers/general_test.go
hugolib/pagination_test.go
hugolib/path_separators_test.go
hugolib/path_separators_windows_test.go
hugolib/shortcode_test.go
parser/frontmatter_test.go
tpl/template_funcs_test.go

index 0147822c77cc0879d3b01ec80afc809176ed59d0..31c478200d59bce360341169bf50e099d57c2b96 100644 (file)
@@ -28,7 +28,7 @@ func TestGuessType(t *testing.T) {
        } {
                result := GuessType(this.in)
                if result != this.expect {
-                       t.Errorf("[%d] GuessType guessed wrong, expected %s, got %s", i, this.expect, result)
+                       t.Errorf("[%d] got %s but expected %s", i, result, this.expect)
                }
        }
 }
@@ -109,7 +109,7 @@ func TestReaderContains(t *testing.T) {
        for i, this := range append(containsBenchTestData, containsAdditionalTestData...) {
                result := ReaderContains(StringToReader(this.v1), this.v2)
                if result != this.expect {
-                       t.Errorf("[%d] Got %t but expected %t", i, result, this.expect)
+                       t.Errorf("[%d] got %t but expected %t", i, result, this.expect)
                }
        }
 
@@ -123,7 +123,7 @@ func BenchmarkReaderContains(b *testing.B) {
                for i, this := range containsBenchTestData {
                        result := ReaderContains(StringToReader(this.v1), this.v2)
                        if result != this.expect {
-                               b.Errorf("[%d] Got %t but expected %t", i, result, this.expect)
+                               b.Errorf("[%d] got %t but expected %t", i, result, this.expect)
                        }
                }
        }
@@ -140,7 +140,7 @@ func _BenchmarkReaderContains(b *testing.B) {
                        }
                        result := bytes.Contains(bs, this.v2)
                        if result != this.expect {
-                               b.Errorf("[%d] Got %t but expected %t", i, result, this.expect)
+                               b.Errorf("[%d] got %t but expected %t", i, result, this.expect)
                        }
                }
        }
@@ -167,10 +167,10 @@ func TestInStringArrayCaseSensitive(t *testing.T) {
                {"Albert", true},
                {"ALBERT", false},
        }
-       for _, in := range data {
+       for i, in := range data {
                output := InStringArray(array, in.input)
                if output != in.expected {
-                       t.Errorf("TestInStringArrayCase failed. Expected %t. Got %t.", in.expected, output)
+                       t.Errorf("[%d] got %t but expected %t", i, output, in.expected)
                }
        }
 }
index f42197ba7fa0b0d64b8f09b8f2758489e0500ebe..5d7dcc3e5470488e4f63666ca3120ad8dc0950f8 100644 (file)
@@ -301,7 +301,7 @@ func TestProbablyEqualPageLists(t *testing.T) {
                result := probablyEqualPageLists(this.v1, this.v2)
 
                if result != this.expect {
-                       t.Errorf("[%d] Got %t but expected %t", i, result, this.expect)
+                       t.Errorf("[%d] got %t but expected %t", i, result, this.expect)
 
                }
        }
index e9af0e9225662518c09ba38a4b86ddb303e227b4..b45d5f331e9846db77a019e268e20a4a7e84382f 100644 (file)
@@ -34,13 +34,13 @@ func TestNewPageWithFilePath(t *testing.T) {
                {filepath.Join("content", "dub", "sub", "foobar.html"), "dub", L("dub/single.html", "_default/single.html")},
        }
 
-       for _, el := range toCheck {
+       for i, el := range toCheck {
                p, err := NewPageFrom(strings.NewReader(SIMPLE_PAGE_YAML), el.input)
                if err != nil {
-                       t.Errorf("Reading from SIMPLE_PAGE_YAML resulted in an error: %s", err)
+                       t.Errorf("[%d] Reading from SIMPLE_PAGE_YAML resulted in an error: %s", i, err)
                }
                if p.Section() != el.section {
-                       t.Errorf("Section not set to %s for page %s. Got: %s", el.section, el.input, p.Section())
+                       t.Errorf("[%d] Section incorrect page %s. got %s but expected %s", i, el.input, p.Section(), el.section)
                }
 
                for _, y := range el.layout {
@@ -48,7 +48,7 @@ func TestNewPageWithFilePath(t *testing.T) {
                }
 
                if !listEqual(p.Layout(), el.layout) {
-                       t.Errorf("Layout incorrect. Expected: '%s', Got: '%s'", el.layout, p.Layout())
+                       t.Errorf("[%d] Layout incorrect. got '%s' but expected '%s'", i, p.Layout(), el.layout)
                }
        }
 }
index 4d8e0c48bcc509690aeabd2e78d326d64150e2e2..8b2cbacfe316698dd4b7f28b67a35517daebb703 100644 (file)
@@ -13,6 +13,6 @@ const (
 func TestTemplatePathSeparator(t *testing.T) {
        tmpl := new(tpl.GoHTMLTemplate)
        if name := tmpl.GenerateTemplateNameFrom(win_base, win_path); name != "sub1/index.html" {
-               t.Fatalf("Template name incorrect.  Expected: %s, Got: %s", "sub1/index.html", name)
+               t.Fatalf("Template name incorrect. got %s but expected %s", name, "sub1/index.html")
        }
 }
index 742a02ffe21945cd2298bd6dd620553eb80a7793..3aa9b1ed29b1a3d7522c0fae4ab246f863efe351 100644 (file)
@@ -27,7 +27,7 @@ func CheckShortCodeMatch(t *testing.T, input, expected string, template tpl.Temp
        }
 
        if output != expected {
-               t.Fatalf("Shortcode render didn't match. Expected: %q, Got: %q", expected, output)
+               t.Fatalf("Shortcode render didn't match. got %q but exxpected %q", output, expected)
        }
 }
 
@@ -260,8 +260,8 @@ func TestExtractShortcodes(t *testing.T) {
                        } else {
                                r, _ := regexp.Compile(this.expectErrorMsg)
                                if !r.MatchString(err.Error()) {
-                                       t.Fatalf("[%d] %s: ExtractShortcodes didn't return an expected error message, expected %s got %s",
-                                               i, this.name, this.expectErrorMsg, err.Error())
+                                       t.Fatalf("[%d] %s: ExtractShortcodes didn't return an expected error message, got %s but expected %s",
+                                               i, this.name, err.Error(), this.expectErrorMsg)
                                }
                        }
                        continue
@@ -289,7 +289,7 @@ func TestExtractShortcodes(t *testing.T) {
                }
 
                if !r.MatchString(content) {
-                       t.Fatalf("[%d] %s: Shortcode extract didn't match. Expected: %q, Got: %q", i, this.name, expected, content)
+                       t.Fatalf("[%d] %s: Shortcode extract didn't match. got %q but expected %q", i, this.name, content, expected)
                }
 
                for placeHolder, sc := range shortCodes {
@@ -305,7 +305,7 @@ func TestExtractShortcodes(t *testing.T) {
                if this.expectShortCodes != "" {
                        shortCodesAsStr := fmt.Sprintf("map%q", collectAndSortShortcodes(shortCodes))
                        if !strings.Contains(shortCodesAsStr, this.expectShortCodes) {
-                               t.Fatalf("[%d] %s: Short codes not as expected, got %s - expected to contain %s", i, this.name, shortCodesAsStr, this.expectShortCodes)
+                               t.Fatalf("[%d] %s: Short codes not as expected, got %s but expected %s", i, this.name, shortCodesAsStr, this.expectShortCodes)
                        }
                }
        }
index 33db0a24a16d4c834de8dbc1db19ff6a8aa07d84..c9c3c0eaae9cb3211f1aaabb587fdc1a4dc967c8 100644 (file)
@@ -19,7 +19,7 @@ func TestFormatToLeadRune(t *testing.T) {
                result := FormatToLeadRune(this.kind)
 
                if result != this.expect {
-                       t.Errorf("[%d] Got %q but expected %q", i, result, this.expect)
+                       t.Errorf("[%d] got %q but expected %q", i, result, this.expect)
                }
        }
 }
index 3a51e741d86f7f0b859815f192413cad62e382dd..b1d611c11243ae31fae588c523566b662c57c202 100644 (file)
@@ -271,7 +271,7 @@ func TestIn(t *testing.T) {
                result := In(this.v1, this.v2)
 
                if result != this.expect {
-                       t.Errorf("[%d] Got %v but expected %v", i, result, this.expect)
+                       t.Errorf("[%d] got %v but expected %v", i, result, this.expect)
                }
        }
 }
@@ -310,7 +310,7 @@ func TestSlicestr(t *testing.T) {
                                continue
                        }
                        if !reflect.DeepEqual(result, this.expect) {
-                               t.Errorf("[%d] Got %s but expected %s", i, result, this.expect)
+                               t.Errorf("[%d] got %s but expected %s", i, result, this.expect)
                        }
                }
        }
@@ -350,7 +350,7 @@ func TestSubstr(t *testing.T) {
                                continue
                        }
                        if !reflect.DeepEqual(result, this.expect) {
-                               t.Errorf("[%d] Got %s but expected %s", i, result, this.expect)
+                               t.Errorf("[%d] got %s but expected %s", i, result, this.expect)
                        }
                }
        }
@@ -380,7 +380,7 @@ func TestSplit(t *testing.T) {
                                continue
                        }
                        if !reflect.DeepEqual(result, this.expect) {
-                               t.Errorf("[%d] Got %s but expected %s", i, result, this.expect)
+                               t.Errorf("[%d] got %s but expected %s", i, result, this.expect)
                        }
                }
        }
@@ -413,20 +413,20 @@ func TestIntersect(t *testing.T) {
                        continue
                }
                if !reflect.DeepEqual(results, this.expect) {
-                       t.Errorf("[%d] Got %v but expected %v", i, results, this.expect)
+                       t.Errorf("[%d] got %v but expected %v", i, results, this.expect)
                }
        }
 
        _, err1 := Intersect("not an array or slice", []string{"a"})
 
        if err1 == nil {
-               t.Error("Excpected error for non array as first arg")
+               t.Error("Expected error for non array as first arg")
        }
 
        _, err2 := Intersect([]string{"a"}, "not an array or slice")
 
        if err2 == nil {
-               t.Error("Excpected error for non array as second arg")
+               t.Error("Expected error for non array as second arg")
        }
 }
 
@@ -1225,3 +1225,4 @@ func TestSafeURL(t *testing.T) {
                }
        }
 }
+