Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Bad formatted message when fmt-verbs included #565

Closed
motemen opened this issue Jun 4, 2021 · 2 comments
Closed

Bad formatted message when fmt-verbs included #565

motemen opened this issue Jun 4, 2021 · 2 comments

Comments

@motemen
Copy link
Contributor

motemen commented Jun 4, 2021

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

With test code with gomock like below:

package eg

import (
	"testing"

	"github.com/golang/mock/gomock"
)

func Test(t *testing.T) {
	ctrl := gomock.NewController(t)
	foo := NewMockFoo(ctrl)
	foo.EXPECT().Foo("%s")
	foo.Foo("x")
}

We get:

--- FAIL: Test (0.00s)
    eg_test.go:14: Unexpected call to *eg.MockFoo.Foo([x]) at /src/eg_test.go:14 because:
        expected call at /src/eg_test.go:12 doesn't match the argument at index 0.
        Got: x
        Want: is equal to %!s(MISSING)
    controller.go:137: missing call(s) to *eg.MockFoo.Foo(is equal to %s) /src/eg_test.go:12
    controller.go:137: aborting test due to missing call(s)

Having %!s(MISSING) unintendedly.

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

We sholud get:

--- FAIL: Test (0.00s)
    eg_test.go:14: Unexpected call to *eg.MockFoo.Foo([x]) at /src/eg_test.go:14 because:
        expected call at /src/eg_test.go:12 doesn't match the argument at index 0.
        Got: x
        Want: is equal to %s
    controller.go:137: missing call(s) to *eg.MockFoo.Foo(is equal to %s) /src/eg_test.go:12
    controller.go:137: aborting test due to missing call(s)

To Reproduce Steps to reproduce the behavior

  1. Clone https://github.com/motemen/example-gomock-ill-formatted-message
  2. Run docker run --rm -v $PWD:/src -w /src golang go test

Additional Information

  • gomock mode (reflect or source): reflect
  • gomock version or git ref: v1.5.0
  • golang version: go version go1.16.4 darwin/amd64

Triage Notes for the Maintainers

@codyoss
Copy link
Member

codyoss commented Jun 4, 2021

@motemen Thanks!

@codyoss
Copy link
Member

codyoss commented Jun 4, 2021

Fixed by #564

@codyoss codyoss closed this as completed Jun 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants