Add tests for errors
This commit is contained in:
parent
12d87226a7
commit
c3a3d38735
41
rpc/messages_test.go
Normal file
41
rpc/messages_test.go
Normal file
@ -0,0 +1,41 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestInsufficientParamsError(t *testing.T) {
|
||||
err := NewInsufficientParamsError(0, 1)
|
||||
expected := "insufficient params, want 1 have 0"
|
||||
|
||||
if err.Error() != expected {
|
||||
t.Error(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func TestNotImplementedError(t *testing.T) {
|
||||
err := NewNotImplementedError("foo")
|
||||
expected := "foo method not implemented"
|
||||
|
||||
if err.Error() != expected {
|
||||
t.Error(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecodeParamError(t *testing.T) {
|
||||
err := NewDecodeParamError("foo")
|
||||
expected := "could not decode, foo"
|
||||
|
||||
if err.Error() != expected {
|
||||
t.Error(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidationError(t *testing.T) {
|
||||
err := NewValidationError("foo", "should be `bar`")
|
||||
expected := "foo not valid, should be `bar`"
|
||||
|
||||
if err.Error() != expected {
|
||||
t.Error(err.Error())
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user