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

Bad formatted message when fmt-verbs included #565

@motemen

Description

@motemen

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions