diff options
author | Taylor Gerring <taylor.gerring@gmail.com> | 2015-03-27 03:04:03 +0800 |
---|---|---|
committer | Taylor Gerring <taylor.gerring@gmail.com> | 2015-03-27 03:04:03 +0800 |
commit | 62ebf999bf71ef05e34e234b6e07cc31188970b7 (patch) | |
tree | 739d2b662ebe945e1f1a2f00fd9619fc2a6fb7d1 /rpc/args_test.go | |
parent | e21ce9a9b48a651a704a92369712c17113d92ad6 (diff) | |
download | dexon-62ebf999bf71ef05e34e234b6e07cc31188970b7.tar.gz dexon-62ebf999bf71ef05e34e234b6e07cc31188970b7.tar.zst dexon-62ebf999bf71ef05e34e234b6e07cc31188970b7.zip |
FilterStringArgs tests
Diffstat (limited to 'rpc/args_test.go')
-rw-r--r-- | rpc/args_test.go | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/rpc/args_test.go b/rpc/args_test.go index 90b283891..9325b1c9b 100644 --- a/rpc/args_test.go +++ b/rpc/args_test.go @@ -1106,10 +1106,6 @@ func TestFilterStringArgs(t *testing.T) { t.Error(err) } - if err := args.requirements(); err != nil { - t.Error(err) - } - if expected.Word != args.Word { t.Errorf("Word shoud be %#v but is %#v", expected.Word, args.Word) } @@ -1119,9 +1115,39 @@ func TestFilterStringEmptyArgs(t *testing.T) { input := `[]` args := new(FilterStringArgs) - err := json.Unmarshal([]byte(input), &args) - if err == nil { - t.Error("Expected error but didn't get one") + str := ExpectInsufficientParamsError(json.Unmarshal([]byte(input), &args)) + if len(str) > 0 { + t.Errorf(str) + } +} + +func TestFilterStringInvalidArgs(t *testing.T) { + input := `{}` + + args := new(FilterStringArgs) + str := ExpectDecodeParamError(json.Unmarshal([]byte(input), &args)) + if len(str) > 0 { + t.Errorf(str) + } +} + +func TestFilterStringWordInt(t *testing.T) { + input := `[7]` + + args := new(FilterStringArgs) + str := ExpectInvalidTypeError(json.Unmarshal([]byte(input), &args)) + if len(str) > 0 { + t.Errorf(str) + } +} + +func TestFilterStringWordWrong(t *testing.T) { + input := `["foo"]` + + args := new(FilterStringArgs) + str := ExpectValidationError(json.Unmarshal([]byte(input), &args)) + if len(str) > 0 { + t.Errorf(str) } } |