From 1e8719e7f4acb0342f62bc3fee478a2136622a37 Mon Sep 17 00:00:00 2001 From: Matt Bell <mappum@gmail.com> Date: Tue, 14 Oct 2014 17:37:14 -0700 Subject: [PATCH] commands: Fixed tests --- commands/command_test.go | 4 ++-- commands/response_test.go | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/commands/command_test.go b/commands/command_test.go index 766dfc7c..47b151fe 100644 --- a/commands/command_test.go +++ b/commands/command_test.go @@ -15,7 +15,7 @@ func TestOptionValidation(t *testing.T) { req.options["foo"] = 5 res := cmd.Call(req) if res.Error == nil { - t.Error("Should have failed (unrecognized command)") + t.Error("Should have failed (unrecognized option)") } req = NewRequest() @@ -37,7 +37,7 @@ func TestOptionValidation(t *testing.T) { req.options["beep"] = 5 res = cmd.Call(req) if res.Error != nil { - t.Error("Should have passed") + t.Error(res.Error, "Should have passed") } req = NewRequest() diff --git a/commands/response_test.go b/commands/response_test.go index 35f8e488..fcd6a398 100644 --- a/commands/response_test.go +++ b/commands/response_test.go @@ -18,15 +18,24 @@ func TestMarshalling(t *testing.T) { 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 { 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() if err != nil { - t.Error("Should have passed") + t.Error(err, "Should have passed") } output := string(bytes) if output != "{\"Foo\":\"beep\",\"Bar\":\"boop\",\"Baz\":1337}" { -- GitLab