Skip to content

Commit 479ec1a

Browse files
committed
fix: UnitTest for invalid proto obj
1 parent f21906a commit 479ec1a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

binding/binding_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,6 +1339,13 @@ func testProtoBodyBindingFail(t *testing.T, b Binding, name, path, badPath, body
13391339
err := b.Bind(req, &obj)
13401340
assert.Error(t, err)
13411341

1342+
invalid_obj := FooStruct{}
1343+
req.Body = ioutil.NopCloser(strings.NewReader(`{"msg":"hello"}`))
1344+
req.Header.Add("Content-Type", MIMEPROTOBUF)
1345+
err = b.Bind(req, &invalid_obj)
1346+
assert.Error(t, err)
1347+
assert.Equal(t, err.Error(), "obj is not ProtoMessage")
1348+
13421349
obj = protoexample.Test{}
13431350
req = requestWithBody("POST", badPath, badBody)
13441351
req.Header.Add("Content-Type", MIMEPROTOBUF)

0 commit comments

Comments
 (0)