Skip to content

Ignore fields using struct tags #843

@hiimoliverwang

Description

@hiimoliverwang

Hello,

Is there a way to ignore certain fields when asserting equal or as the argument of .On?

e.g.

type A struct {
  Name string
  UpdatedAt time.Time `mock: "ignore"`
}

expected := A{
    Name: "Expected Name"
}
mocks.MockController.On("Update", expected).Return(whatever)
...

We don't really care about the UpdateAt time, and this would also apply to random UUID's etc.
Otherwise we would have to assert each sub field in order for the test to pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    assert.EqualValuesAbout equalitypkg-assertChange related to package testify/assertpkg-requireChange related to package testify/require

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions