Commit d0bca09f authored by Matt Bell's avatar Matt Bell Committed by Juan Batiz-Benet

commands: Added test for Response error marshalling

parent 6e05d051
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")
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment