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

commands: Wrote tests for Response marshalling

parent a3a84375
package commands
import "testing"
type TestOutput struct {
Foo, Bar string
Baz int
}
func TestMarshalling(t *testing.T) {
req := NewRequest()
res := Response{
req: req,
Value: TestOutput{ "beep", "boop", 1337 },
}
_, err := res.Marshal()
if err == nil {
t.Error("Should have failed (no encoding type specified in request)")
}
req.options["enc"] = Json
bytes, err := res.Marshal()
if err != nil {
t.Error("Should have passed")
}
output := string(bytes)
if output != "{\"Foo\":\"beep\",\"Bar\":\"boop\",\"Baz\":1337}" {
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