Skip to content

Commit

Permalink
fix: UnitTest for invalid proto obj
Browse files Browse the repository at this point in the history
Change-Id: I0e951d272de1386a8ef1b8ba8ae78169b0026c83
  • Loading branch information
Tevic committed Sep 1, 2021
1 parent f21906a commit 026d958
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 = io.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 026d958

Please sign in to comment.