Skip to content

Mock panics when argument of nil type checked against AnythingOfType #1209

@brackendawson

Description

@brackendawson

Reported by @cfiderer: #1155 (comment)

Raising a new issue because I think the fix to 1155 will not fix this.

This deadlocks in testify v1.7.4:

package kata

import (
	"testing"

	"github.com/stretchr/testify/mock"
)

type mockThing struct {
	mock.Mock
}

func (m *mockThing) Do(arg interface{}) string {
	return m.Called(arg).String(0)
}

func TestTestify(t *testing.T) {
	m := &mockThing{}
	defer m.AssertExpectations(t)
	m.On("Do", mock.AnythingOfType("string")).Return("Nae")
	m.Do(nil)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    mock.ArgumentMatcherAbout matching arguments in mockpkg-mockAny issues related to Mock

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions