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

commands: Fixed tests

parent c575b508
...@@ -15,7 +15,7 @@ func TestOptionValidation(t *testing.T) { ...@@ -15,7 +15,7 @@ func TestOptionValidation(t *testing.T) {
req.options["foo"] = 5 req.options["foo"] = 5
res := cmd.Call(req) res := cmd.Call(req)
if res.Error == nil { if res.Error == nil {
t.Error("Should have failed (unrecognized command)") t.Error("Should have failed (unrecognized option)")
} }
req = NewRequest() req = NewRequest()
...@@ -37,7 +37,7 @@ func TestOptionValidation(t *testing.T) { ...@@ -37,7 +37,7 @@ func TestOptionValidation(t *testing.T) {
req.options["beep"] = 5 req.options["beep"] = 5
res = cmd.Call(req) res = cmd.Call(req)
if res.Error != nil { if res.Error != nil {
t.Error("Should have passed") t.Error(res.Error, "Should have passed")
} }
req = NewRequest() req = NewRequest()
......
...@@ -18,15 +18,24 @@ func TestMarshalling(t *testing.T) { ...@@ -18,15 +18,24 @@ func TestMarshalling(t *testing.T) {
Value: TestOutput{"beep", "boop", 1337}, Value: TestOutput{"beep", "boop", 1337},
} }
_, err := res.Marshal() // get command global options so we can set the encoding option
cmd := Command{}
options, err := cmd.GetOptions(nil)
if err != nil {
t.Error(err)
}
_, err = res.Marshal()
if err == nil { if err == nil {
t.Error("Should have failed (no encoding type specified in request)") t.Error("Should have failed (no encoding type specified in request)")
} }
req.SetOption(globalOptions[0], Json) req.SetOption("enc", Json)
req.convertOptions(options)
bytes, err := res.Marshal() bytes, err := res.Marshal()
if err != nil { if err != nil {
t.Error("Should have passed") t.Error(err, "Should have passed")
} }
output := string(bytes) output := string(bytes)
if output != "{\"Foo\":\"beep\",\"Bar\":\"boop\",\"Baz\":1337}" { if output != "{\"Foo\":\"beep\",\"Bar\":\"boop\",\"Baz\":1337}" {
......
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