Skip to content

Commit

Permalink
commands: Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mappum committed Oct 21, 2014
1 parent dd84a3e commit 4f10f03
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions commands/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,66 +13,66 @@ func TestOptionValidation(t *testing.T) {

req := NewEmptyRequest()
req.SetOption("foo", 5)
res := cmd.Call(req, nil)
res := cmd.Call(req)
if res.Error() == nil {
t.Error("Should have failed (unrecognized option)")
}

req = NewEmptyRequest()
req.SetOption("beep", 5)
req.SetOption("b", 10)
res = cmd.Call(req, nil)
res = cmd.Call(req)
if res.Error() == nil {
t.Error("Should have failed (duplicate options)")
}

req = NewEmptyRequest()
req.SetOption("beep", "foo")
res = cmd.Call(req, nil)
res = cmd.Call(req)
if res.Error() == nil {
t.Error("Should have failed (incorrect type)")
}

req = NewEmptyRequest()
req.SetOption("beep", 5)
res = cmd.Call(req, nil)
res = cmd.Call(req)
if res.Error() != nil {
t.Error(res.Error(), "Should have passed")
}

req = NewEmptyRequest()
req.SetOption("beep", 5)
req.SetOption("boop", "test")
res = cmd.Call(req, nil)
res = cmd.Call(req)
if res.Error() != nil {
t.Error("Should have passed")
}

req = NewEmptyRequest()
req.SetOption("b", 5)
req.SetOption("B", "test")
res = cmd.Call(req, nil)
res = cmd.Call(req)
if res.Error() != nil {
t.Error("Should have passed")
}

req = NewEmptyRequest()
req.SetOption(EncShort, "json")
res = cmd.Call(req, nil)
res = cmd.Call(req)
if res.Error() != nil {
t.Error("Should have passed")
}

req = NewEmptyRequest()
req.SetOption("b", "100")
res = cmd.Call(req, nil)
res = cmd.Call(req)
if res.Error() != nil {
t.Error("Should have passed")
}

req = NewEmptyRequest()
req.SetOption("b", ":)")
res = cmd.Call(req, nil)
res = cmd.Call(req)
if res.Error == nil {
t.Error(res.Error, "Should have failed (string value not convertible to int)")
}
Expand Down
2 changes: 1 addition & 1 deletion commands/response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type TestOutput struct {
func TestMarshalling(t *testing.T) {
req := NewEmptyRequest()

res := NewResponse(req, nil)
res := NewResponse(req)
res.SetValue(TestOutput{"beep", "boop", 1337})

// get command global options so we can set the encoding option
Expand Down

0 comments on commit 4f10f03

Please sign in to comment.