aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-03-20 12:08:29 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-03-20 12:08:29 +0800
commitc3a3d387352cf9cf626dc67e0aeaaa68c4bc651a (patch)
treef114cb6069137b75fbca339bd00ad7357c90828b
parent12d87226a74d3c4095ea8e189c30ff31fcadf59f (diff)
downloaddexon-c3a3d387352cf9cf626dc67e0aeaaa68c4bc651a.tar
dexon-c3a3d387352cf9cf626dc67e0aeaaa68c4bc651a.tar.gz
dexon-c3a3d387352cf9cf626dc67e0aeaaa68c4bc651a.tar.bz2
dexon-c3a3d387352cf9cf626dc67e0aeaaa68c4bc651a.tar.lz
dexon-c3a3d387352cf9cf626dc67e0aeaaa68c4bc651a.tar.xz
dexon-c3a3d387352cf9cf626dc67e0aeaaa68c4bc651a.tar.zst
dexon-c3a3d387352cf9cf626dc67e0aeaaa68c4bc651a.zip
Add tests for errors
-rw-r--r--rpc/messages_test.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/rpc/messages_test.go b/rpc/messages_test.go
new file mode 100644
index 000000000..5274c91e4
--- /dev/null
+++ b/rpc/messages_test.go
@@ -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())
+ }
+}