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

Wrong print msg when comparing initialized and uninitialized slice #69

Open
samlaf opened this issue Aug 25, 2023 · 1 comment · May be fixed by #79
Open

Wrong print msg when comparing initialized and uninitialized slice #69

samlaf opened this issue Aug 25, 2023 · 1 comment · May be fixed by #79
Labels
bug Something isn't working

Comments

@samlaf
Copy link

samlaf commented Aug 25, 2023

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

=== RUN   TestA
    tests/A_test.go:15: Unexpected call to *tests.MockAer.Hello([[]]) at tests/A_test.go:15 because:
        expected call at tests/A_test.go:14 doesn't match the argument at index 0.
        Got: [] ([][32]uint8)
        Want: is equal to [] ([][32]uint8)

Expected behavior

=== RUN   TestA
    tests/A_test.go:15: Unexpected call to *tests.MockAer.Hello([[]]) at tests/A_test.go:15 because:
        expected call at tests/A_test.go:14 doesn't match the argument at index 0.
        Got: nil ([][32]uint8)
        Want: is equal to [] ([][32]uint8)

To Reproduce Steps to reproduce the behavior

Generate mocks for this interface

type Aer interface {
	Hello([][32]byte)
}

Then write this test

func TestA(t *testing.T) {
	ctrl := gomock.NewController(t)
	mockA := NewMockAer(ctrl)
	mockA.EXPECT().Hello([][32]byte{})
	mockA.Hello(nil)
}

You will reproduce the above error, which is very confusing. It's showing that Got and Want are the same, even though they actually aren't.

Additional Information

  • gomock mode (reflect or source): not sure what this means.
  • gomock version or git ref: go.uber.org/mock v0.2.0
  • golang version: go version go1.20.6 darwin/arm64
@r-hang r-hang added the bug Something isn't working label Aug 29, 2023
@deansg
Copy link

deansg commented Apr 10, 2024

Just wanted to mention that a similar issue was opened and not fixed in the archived golang/mock repo:
golang/mock#267
(it was merged into a different issue, whose solution didn't solve the original issue)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants