Browse Source

Improve TestToJson.

Ian Adam Naval 5 years ago
parent
commit
65c29fef11
1 changed files with 10 additions and 2 deletions
  1. 10
    2
      common_test.go

+ 10
- 2
common_test.go View File

@@ -5,9 +5,17 @@ import "testing"
5 5
 func TestToJson(t *testing.T) {
6 6
 	fixture := JshOutput{[]string{}, []string{}}
7 7
 	json := fixture.ToJson()
8
-	expected := "{\"StdOut\":[],\"StdErr\":[]}"
8
+	expected := `{"StdOut":[],"StdErr":[]}`
9 9
 	actual := *json
10 10
 	if actual != expected {
11
-		t.Error("Empty fixture did not match:\n%s != %s", expected, actual)
11
+		t.Errorf("Empty fixture did not match:\n%s != %s", expected, actual)
12
+	}
13
+
14
+	fixture = JshOutput{[]string{"potato!"}, []string{}}
15
+	json = fixture.ToJson()
16
+	expected = `{"StdOut":["potato!"],"StdErr":[]}`
17
+	actual = *json
18
+	if actual != expected {
19
+		t.Errorf("JSON output did not match:\n%s != %s", expected, actual)
12 20
 	}
13 21
 }

Loading…
Cancel
Save