hugo

Unnamed repository; edit this file 'description' to name the repository.

git clone git://git.shimmy1996.com/hugo.git
commit aae6fa0b6b6319187992231baf773768585820d6
parent be37c0b37a244527a2c85b3f55e5aad5b5195a36
Author: spf13 <steve.francia@gmail.com>
Date:   Tue,  8 Apr 2014 21:57:25 -0400

Fix test to not fail when order is different, but slice contents are the same.

Diffstat:
Mhugolib/site_show_plan_test.go | 29++++++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)
diff --git a/hugolib/site_show_plan_test.go b/hugolib/site_show_plan_test.go
@@ -2,9 +2,11 @@ package hugolib
 
 import (
 	"bytes"
+	"strings"
+	"testing"
+
 	"github.com/spf13/hugo/source"
 	"github.com/spf13/hugo/target"
-	"testing"
 )
 
 const ALIAS_DOC_1 = "---\ntitle: alias doc\naliases:\n  - \"alias1/\"\n  - \"alias-2/\"\n---\naliases\n"
@@ -24,14 +26,35 @@ var fakeSource = []source.ByteSource{
 	},
 }
 
+func stringInSlice(a string, list []string) bool {
+	for _, b := range list {
+		if b == a {
+			return true
+		}
+	}
+	return false
+}
+
 func checkShowPlanExpected(t *testing.T, s *Site, expected string) {
 	out := new(bytes.Buffer)
 	if err := s.ShowPlan(out); err != nil {
 		t.Fatalf("ShowPlan unexpectedly returned an error: %s", err)
 	}
 	got := out.String()
-	if got != expected {
-		t.Errorf("ShowPlan expected:\n%q\ngot\n%q", expected, got)
+
+	gotList := strings.Split(got, "\n")
+	expectedList := strings.Split(expected, "\n")
+
+	for _, x := range gotList {
+		if !stringInSlice(x, expectedList) {
+			t.Errorf("ShowPlan expected:\n%q\ngot\n%q", expected, got)
+		}
+	}
+
+	for _, x := range expectedList {
+		if !stringInSlice(x, gotList) {
+			t.Errorf("ShowPlan expected:\n%q\ngot\n%q", expected, got)
+		}
 	}
 }