Commit b74f5b93 authored by Matt Bell's avatar Matt Bell

commands; Fixed tests for Reader output

parent 72872208
package commands
import (
"bytes"
"fmt"
"strings"
"testing"
......@@ -27,21 +28,25 @@ func TestMarshalling(t *testing.T) {
req.SetOption(EncShort, JSON)
bytes, err := res.Marshal()
reader, err := res.Marshal()
if err != nil {
t.Error(err, "Should have passed")
}
output := string(bytes)
var buf bytes.Buffer
buf.ReadFrom(reader)
output := buf.String()
if removeWhitespace(output) != "{\"Foo\":\"beep\",\"Bar\":\"boop\",\"Baz\":1337}" {
t.Error("Incorrect JSON output")
}
res.SetError(fmt.Errorf("Oops!"), ErrClient)
bytes, err = res.Marshal()
reader, err = res.Marshal()
if err != nil {
t.Error("Should have passed")
}
output = string(bytes)
buf.Reset()
buf.ReadFrom(reader)
output = buf.String()
fmt.Println(removeWhitespace(output))
if removeWhitespace(output) != "{\"Message\":\"Oops!\",\"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