From 2071940248cfdf432eb69f3cfec7d9045a497500 Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Fri, 10 Oct 2014 14:00:02 -0700 Subject: [PATCH] commands: Added test for Respone error marshalling --- commands/response_test.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/commands/response_test.go b/commands/response_test.go index a7b1a795d689..e1a96676d230 100644 --- a/commands/response_test.go +++ b/commands/response_test.go @@ -1,6 +1,9 @@ package commands -import "testing" +import ( + "testing" + "fmt" +) type TestOutput struct { Foo, Bar string @@ -29,4 +32,14 @@ func TestMarshalling(t *testing.T) { if output != "{\"Foo\":\"beep\",\"Bar\":\"boop\",\"Baz\":1337}" { t.Error("Incorrect JSON output") } + + res.SetError(fmt.Errorf("You broke something!"), Client) + bytes, err = res.Marshal() + if err != nil { + t.Error("Should have passed") + } + output = string(bytes) + if output != "{\"Message\":\"You broke something!\",\"Code\":1}" { + t.Error("Incorrect JSON output") + } }