shithub: hugo

Download patch

ref: bcdad02c06a2ceb2d9359506279ada05509d68f7
parent: e1340c060bc52c95116bf0d5105a6c0d44bb67e6
author: bep <[email protected]>
date: Tue Mar 17 14:14:29 EDT 2015

Use ReaderToString in site tests

Since a string is what's really needed.

--- a/hugolib/site_test.go
+++ b/hugolib/site_test.go
@@ -372,13 +372,15 @@
 
 	for _, test := range tests {
 		file, err := hugofs.DestinationFS.Open(test.doc)
+
 		if err != nil {
 			t.Fatalf("Did not find %s in target: %s", test.doc, err)
 		}
-		content := helpers.ReaderToBytes(file)
 
-		if !bytes.Equal(content, []byte(test.expected)) {
-			t.Errorf("%s content expected:\n%q\ngot:\n%q", test.doc, test.expected, string(content))
+		content := helpers.ReaderToString(file)
+
+		if content != test.expected {
+			t.Errorf("%s content expected:\n%q\ngot:\n%q", test.doc, test.expected, content)
 		}
 	}
 
@@ -446,10 +448,11 @@
 		if err != nil {
 			t.Fatalf("Did not find %s in target: %s", test.doc, err)
 		}
-		content := helpers.ReaderToBytes(file)
 
-		if !bytes.Equal(content, []byte(test.expected)) {
-			t.Errorf("%s content expected:\n%q\ngot:\n%q", test.doc, test.expected, string(content))
+		content := helpers.ReaderToString(file)
+
+		if content != test.expected {
+			t.Errorf("%s content expected:\n%q\ngot:\n%q", test.doc, test.expected, content)
 		}
 	}
 
@@ -504,10 +507,11 @@
 		if err != nil {
 			t.Fatalf("Did not find %s in target.", test.doc)
 		}
-		content := helpers.ReaderToBytes(file)
 
-		if !bytes.Equal(content, []byte(test.expected)) {
-			t.Errorf("%s content expected:\n%q\ngot:\n%q", test.doc, test.expected, string(content))
+		content := helpers.ReaderToString(file)
+
+		if content != test.expected {
+			t.Errorf("%s content expected:\n%q\ngot:\n%q", test.doc, test.expected, content)
 		}
 	}
 }
@@ -555,14 +559,17 @@
 			if err != nil {
 				t.Fatalf("Unable to locate rendered content: %s", test.file)
 			}
-			content := helpers.ReaderToBytes(file)
 
+			content := helpers.ReaderToString(file)
+
 			expected := test.expected
+
 			if !canonify {
 				expected = strings.Replace(expected, viper.GetString("baseurl"), "", -1)
 			}
-			if string(content) != expected {
-				t.Errorf("AbsUrlify content expected:\n%q\ngot\n%q", expected, string(content))
+
+			if content != expected {
+				t.Errorf("AbsUrlify content expected:\n%q\ngot\n%q", expected, content)
 			}
 		}
 	}