@cryptotaxi247 / kubo / commits / 94ca2642a

commands: Added test for Response error marshalling

Matt Bell committed Oct 10, 2014 at 14:00 UTC 94ca2642a13af96a04f8c2e2cc0eec72676efda3
1 file changed +14 -1
commands/response_test.go
+14 -1
@@ -1,6 +1,9 @@
1 package commands
2
3 -import "testing"
3 +import (
4 + "testing"
5 + "fmt"
6 +)
7
8 type TestOutput struct {
9 Foo, Bar string
@@ -29,4 +32,14 @@ func TestMarshalling(t *testing.T) {
32 if output != "{\"Foo\":\"beep\",\"Bar\":\"boop\",\"Baz\":1337}" {
33 t.Error("Incorrect JSON output")
34 }
35 +
36 + res.SetError(fmt.Errorf("You broke something!"), Client)
37 + bytes, err = res.Marshal()
38 + if err != nil {
39 + t.Error("Should have passed")
40 + }
41 + output = string(bytes)
42 + if output != "{\"Message\":\"You broke something!\",\"Code\":1}" {
43 + t.Error("Incorrect JSON output")
44 + }
45 }