mirror of
https://github.com/sourcegraph/jsonrpc2.git
synced 2026-07-02 15:23:41 +02:00
do not suppress error in TestAnyMessage
This commit is contained in:
parent
c0f3aff61f
commit
9edf388fe1
1 changed files with 9 additions and 4 deletions
|
|
@ -8,11 +8,11 @@ import (
|
||||||
|
|
||||||
func TestAnyMessage(t *testing.T) {
|
func TestAnyMessage(t *testing.T) {
|
||||||
tests := map[string]struct {
|
tests := map[string]struct {
|
||||||
request, response bool
|
request, response, invalid bool
|
||||||
}{
|
}{
|
||||||
// Single messages
|
// Single messages
|
||||||
`{}`: {},
|
`{}`: {invalid: true},
|
||||||
`{"foo":"bar"}`: {},
|
`{"foo":"bar"}`: {invalid: true},
|
||||||
`{"method":"m"}`: {request: true},
|
`{"method":"m"}`: {request: true},
|
||||||
`{"result":123}`: {response: true},
|
`{"result":123}`: {response: true},
|
||||||
`{"result":null}`: {response: true},
|
`{"result":null}`: {response: true},
|
||||||
|
|
@ -20,7 +20,12 @@ func TestAnyMessage(t *testing.T) {
|
||||||
}
|
}
|
||||||
for s, want := range tests {
|
for s, want := range tests {
|
||||||
var m anyMessage
|
var m anyMessage
|
||||||
json.Unmarshal([]byte(s), &m)
|
if err := json.Unmarshal([]byte(s), &m); err != nil {
|
||||||
|
if !want.invalid {
|
||||||
|
t.Errorf("%s: error: %s", s, err)
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
if (m.request != nil) != want.request {
|
if (m.request != nil) != want.request {
|
||||||
t.Errorf("%s: got request %v, want %v", s, m.request != nil, want.request)
|
t.Errorf("%s: got request %v, want %v", s, m.request != nil, want.request)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue