Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssertCalled makes deep comparison but shallow print #896

Open
benzaita opened this issue Feb 23, 2020 · 1 comment · May be fixed by #926
Open

AssertCalled makes deep comparison but shallow print #896

benzaita opened this issue Feb 23, 2020 · 1 comment · May be fixed by #926

Comments

@benzaita
Copy link

I have a func Dispatch(something interface{}) which is used by the code I want to test. That code looks something like this:

dispatcher.Dispatch(&Something{Name: "foo"})

Calling mockDispatcher.AssertCalled(t, "Dispatch", &Something{Name: "foo"}) passes, as expected.

But when I write a test that calls mockDispatcher.AssertCalled(t, "Dispatch", &Something{Name: "bar"}) it fails with an error like:

        	Messages:   	Expected "Dispatch" to have been called with:
        	            	[0xc00009c800]
        	            	but actual calls were:
        	            	        [0xc000083030]

This is misleading, as I thought the problem was that testify does not do a deep comparison (which is wrong, judging by the passing test).

I'd expect the printed message to be a bit more verbose so the user can tell it's a problem with the values referenced by the pointer, not the pointer itself.

@boyan-soubachov
Copy link
Collaborator

Very good point. If you wish to write a PR that would solve this, I'd be happy to help out and merge :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants