Skip to content

Commit

Permalink
fix: UnitTest for invalid proto obj
Browse files Browse the repository at this point in the history
  • Loading branch information
Tevic committed Sep 2, 2021
1 parent f21906a commit 479ec1a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions binding/binding_test.go
Expand Up @@ -1339,6 +1339,13 @@ func testProtoBodyBindingFail(t *testing.T, b Binding, name, path, badPath, body
err := b.Bind(req, &obj)
assert.Error(t, err)

invalid_obj := FooStruct{}
req.Body = ioutil.NopCloser(strings.NewReader(`{"msg":"hello"}`))
req.Header.Add("Content-Type", MIMEPROTOBUF)
err = b.Bind(req, &invalid_obj)
assert.Error(t, err)
assert.Equal(t, err.Error(), "obj is not ProtoMessage")

obj = protoexample.Test{}
req = requestWithBody("POST", badPath, badBody)
req.Header.Add("Content-Type", MIMEPROTOBUF)
Expand Down

0 comments on commit 479ec1a

Please sign in to comment.