golang / mock

GoMock is a mocking framework for the Go programming language.
Apache License 2.0
9.28k stars 610 forks source link

Error when constants are used in arguments list #605

Closed akhilravuri-tul-scm closed 2 years ago

akhilravuri-tul-scm commented 2 years ago

Actual behavior A clear and concise description of what the bug is.

=== RUN Test_queryResolver_SellersByStatus ========== My Debug Print context.Background sam_id:"2" status:"PFA" per_page:2 page_no:1 count:true ==========My Debug Print === RUN Test_queryResolver_SellersByStatus/TestCase_1 --- PASS: Test_queryResolver_SellersByStatus (0.00s) --- PASS: Test_queryResolver_SellersByStatus/TestCase_1 (0.00s) PASS ok gateway_msvc/query/gty_qry_bo/graph 0.547s

Expected behavior A clear and concise description of what you expected to happen.

Running tool: /usr/local/go/bin/go test -timeout 30s -run ^Test_queryResolver_SellersByStatus$ query/gty_qry_bo/graph

=== RUN Test_queryResolver_SellersByStatus === RUN Test_queryResolver_SellersByStatus/TestCase_1 sam_id:"2" status:"PFA" per_page:2 page_no:1 count:true === CONT Test_queryResolver_SellersByStatus graph/schema.resolvers.go:56: Unexpected call to mocks.MockBoQueryClient.GetSellersByStatus([context.Background sam_id:"2" status:"PFA" per_page:2 page_no:1 count:true]) at gty_qry_bo/graph/schema.resolvers.go:56 because: expected call at /gty_qry_bo/graph/internal_schema.resolvers_test.go:52 doesn't match the argument at index 1. Got: sam_id:"2" status:"PFA" per_page:2 page_no:1 count:true (generated.SellersByStatusRequest) Want: is equal to sam_id:"2" status:"PFA" per_page:2 page_no:1 count:true (generated.SellersByStatusRequest) expected call at /graph/internal_schema.resolvers_test.go:64 doesn't match the argument at index 1. Got: sam_id:"2" status:"PFA" per_page:2 page_no:1 count:true (generated.SellersByStatusRequest) Want: is equal to sam_id:"2" status:"PFA" per_page:2 page_no:2 count:true (generated.SellersByStatusRequest) === CONT Test_queryResolver_SellersByStatus/TestCase_1 /graph/testing.go:1169: test executed panic(nil) or runtime.Goexit: subtest may have called FailNow on a parent test === CONT Test_queryResolver_SellersByStatus gty_qry_bo/graph/controller.go:137: missing call(s) to mocks.MockBoQueryClient.GetSellersByStatus(is equal to context.Background (context.emptyCtx), is equal to sam_id:"2" status:"PFA" per_page:2 page_no:1 count:true (generated.SellersByStatusRequest)) gty_qry_bo/graph/internal_schema.resolvers_test.go:52 gty_qry_bo/graph/controller.go:137: missing call(s) to mocks.MockBoQueryClient.GetSellersByStatus(is equal to context.Background (context.emptyCtx), is equal to sam_id:"2" status:"PFA" per_page:2 page_no:2 count:true (*generated.SellersByStatusRequest)) gty_qry_bo/graph/internal_schema.resolvers_test.go:64 gty_qry_bo/graph/controller.go:137: aborting test due to missing call(s) --- FAIL: Test_queryResolver_SellersByStatus (0.00s) --- FAIL: Test_queryResolver_SellersByStatus/TestCase_1 (0.00s) FAIL FAIL gateway_msvc/query/gty_qry_bo/graph 0.464s

To Reproduce Steps to reproduce the behavior

  1. Write mock test for function contains int64 as a argument.
  2. and execute the test case.
  3. Strange Thing is if I add fmt.Println() in generated mock file/recorder function all the test cases are passed.

Additional Information

Triage Notes for the Maintainers

codyoss commented 2 years ago

@akhilravuri2 Would you mind providing a some minimal code to reproduce this issue, thanks.

codyoss commented 2 years ago

Closing due to lack of response.