Skip to content

Bug: -with-resets does not support interfaces with Generics #228

@andrewradamis-vividseats

Description

-with-resets is currently generating Reset{{.Name}}Calls() and ResetCalls() without Generic Types

//go:generate moq -with-resets -out ./mock.go  ResetStoreGeneric
type ResetStoreGeneric[T, S any] interface {
	Get(ctx context.Context, id T) (string, error)
	Create(ctx context.Context, id T, value S) error
}

Generates

// ResetCreateCalls reset all the calls that were made to Create.
func (mock *ResetStoreGenericMock) ResetCreateCalls() {
	mock.lockCreate.Lock()
	mock.calls.Create = nil
	mock.lockCreate.Unlock()
}

// ResetGetCalls reset all the calls that were made to Get.
func (mock *ResetStoreGenericMock) ResetGetCalls() {
	mock.lockGet.Lock()
	mock.calls.Get = nil
	mock.lockGet.Unlock()
}

// ResetCalls reset all the calls that were made to all mocked methods.
func (mock *ResetStoreGenericMock) ResetCalls() {
	mock.lockCreate.Lock()
	mock.calls.Create = nil
	mock.lockCreate.Unlock()

	mock.lockGet.Lock()
	mock.calls.Get = nil
	mock.lockGet.Unlock()
}

Instead of expected:

// ResetCreateCalls reset all the calls that were made to Create.
func (mock *ResetStoreGenericMock[T, S]) ResetCreateCalls() {
	mock.lockCreate.Lock()
	mock.calls.Create = nil
	mock.lockCreate.Unlock()
}

// ResetGetCalls reset all the calls that were made to Get.
func (mock *ResetStoreGenericMock[T, S]) ResetGetCalls() {
	mock.lockGet.Lock()
	mock.calls.Get = nil
	mock.lockGet.Unlock()
}

// ResetCalls reset all the calls that were made to all mocked methods.
func (mock *ResetStoreGenericMock[T, S]) ResetCalls() {
	mock.lockCreate.Lock()
	mock.calls.Create = nil
	mock.lockCreate.Unlock()

	mock.lockGet.Lock()
	mock.calls.Get = nil
	mock.lockGet.Unlock()
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions