Skip to content

Commit

Permalink
commands: Added test for Respone error marshalling
Browse files Browse the repository at this point in the history
  • Loading branch information
mappum committed Oct 10, 2014
1 parent 77afb23 commit 2071940
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion commands/response_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package commands

import "testing"
import (
"testing"
"fmt"
)

type TestOutput struct {
Foo, Bar string
Expand Down Expand Up @@ -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")
}
}

0 comments on commit 2071940

Please sign in to comment.