Skip to content

Add a matcher for checking a string parameter against regex #113

@merrett010

Description

@merrett010

Requested feature

I've found times where it would be useful to check that string parameters being passed to a function match against some regex.

A specific example could be an SQS message body string containing a UUID that was generated during execution and I won't know what it is ahead of time, but I want to check against the majority of the body being passed to the mock, even though I don't care exactly what the UUID is.

sqsClient.
  EXPECT().
  SendMessage(gomock.AssignableToTypeOf(context.Background()), gomock.Regex(expectedMessageBodyRegex))

Why the feature is needed

I've created a custom matcher for my use cases, but thought I'd offer it up here with an issue and PR in case you could see it being useful.

(Optional) Proposed solution

PR to follow very shortly, see below

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