stretchr / testify

A toolkit with common assertions and mocks that plays nicely with the standard library
MIT License
23.45k stars 1.6k forks source link

Mock report "Unexpected Method Call",but the arguments on two method are binary equal. #30

Closed AlexLuya closed 10 years ago

AlexLuya commented 10 years ago

Sorry,to ask question like this.I have taken half an hour to figure out what the problem is,but failed to identify it,may be I misunderstand something,

I got an error like blow,and I checked arguments of two method calls,no difference.I assumed if arguments are identical,testify mock should work,am I right?

mock: Unexpected Method Call

ToCache(string,*initdata.InitDataForVisitor) 0: user/00001-friendGroup/001 1: &{{} {{false 0 0 false} 0 user/00001} user/00001-friendGroup/001 [] [{ friend/0001}] [] [] []}

The closest call I have is:

ToCache(string,*initdata.InitDataForVisitor) 0: user/00001-friendGroup/001 1: &{{} {{false 0 0 false} 0 user/00001} user/00001-friendGroup/001 [] [{ friend/0001}] [] [] []} [recovered] panic:

matryer commented 10 years ago

Can you check the address of the object? They might be different.

If they are different but similar, consider using mock.Anything as the argument and check the values afterwards.

Sent from my iPhone

On Jan 2, 2014, at 7:11 PM, Alex Luya notifications@github.com wrote:

Sorry,to ask question like this.I have taken half an hour to figure out what the problem is,but failed to identify it,may be I misunderstand something,

I got an error like blow,and I checked arguments of two method calls,no difference.I assumed if arguments are identical,testify mock should work,right?

mock: Unexpected Method Call

ToCache(string,*initdata.InitDataForVisitor) 0: user/00001-friendGroup/001 1: &{{} {{false 0 0 false} 0 user/00001} user/00001-friendGroup/001 [] [{ friend/0001}] [] [] []}

The closest call I have is:

ToCache(string,*initdata.InitDataForVisitor) 0: user/00001-friendGroup/001 1: &{{} {{false 0 0 false} 0 user/00001} user/00001-friendGroup/001 [] [{ friend/0001}] [] [] []} [recovered] panic:

— Reply to this email directly or view it on GitHub.