Unexpected Method Call
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start with the reported mockDynamo.PutItem implementation and its ExpectPutItem helper, then reproduce the failure in TestInvokeEvents using the shown dynamodb.PutItemInput. Compare the expected and actual values, especially the proto.Marshal bytes in the B field, and verify the result against testify's argument-matching behavior. Done means explaining why equivalent-looking calls differ and identifying a reliable matching behavior.
Written by the indexing model from the issue text.
Description
I'm trying to mock PutItem(*dynamodb.PutItemInput) from AWS Dynamo Package GoDoc here
However, I'm running into a bunch of problems that look something like this:
--- FAIL: TestInvokeEvents (0.00s)
panic:
mock: Unexpected Method Call
-----------------------------
PutItem(*dynamodb.PutItemInput)
0: {
Item: {
account#user: {
S: "2#b396abf06c7264027a0a2d037d5ccc25"
},
time#name#id: {
S: "1642501880#pageView#9c7e33a0-9a2f-4372-b5bf-ef20a9995d29"
},
proto_message: {
B: <binary> len 348
}
},
TableName: "test_table"
}
The closest call I have is:
PutItem(*dynamodb.PutItemInput)
0: {
Item: {
account#user: {
S: "2#b396abf06c7264027a0a2d037d5ccc25"
},
time#name#id: {
S: "1642501880#pageView#9c7e33a0-9a2f-4372-b5bf-ef20a9995d29"
},
proto_message: {
B: <binary> len 348
}
},
TableName: "test_table"
}
[recovered]
panic:
I've tried a couple of things:
- Check for types:
func (md *mockDynamo) PutItem(input *dynamodb.PutItemInput) (*dynamodb.PutItemOutput, error) {
args := md.Called(input)
return args.Get(0).(*dynamodb.PutItemOutput), args.Error(1)
}
func (db *mockDynamo) ExpectPutItem(putItemInput *dynamodb.PutItemInput, putItemOutput *dynamodb.PutItemOutput, withErr error) {
db.On("PutItem", putItemInput).Return(putItemOutput, withErr).Once()
}
- Removed the .Once() to make sure it's not being called multiple times..
What I've found after debugging this for about 5-6 hours is that the issue seemed to be near the B: <binary> len 348, which is the bytes result coming from proto.Marshal, removing the bytes from being included in the object resulted in the type passing.
Currently I've been able to workaround the issue by using mock.Anything, however it would be great to know as to why this is even happening!
Much appreciated and looking forward to chasing this down!
-- Robin
- Dominant language
- Go
- Stars
- 26.2k
- Forks
- 1.9k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from stretchr/testify
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
internal/cleanup
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
All issues in stretchr/testify
Similar issues
-
optimization optimization:agents-md-curator
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
githubnext/gh-aw-cao#13143 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
blinklabs-io/bursa#904 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
yanet-platform/ipfw-go#129 ·
-
bug confmap/provider/googlesecretmanagerprovider needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
open-telemetry/opentelemetry-collector-contrib#51273 · 2 comments ·
-
bug: AI Gateway client filter lists "Unknown" twice when NULL and literal Unknown clients coexist Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 90/100