Add a matcher for checking a string parameter against regex
merrett010 opened this issue · 0 comments
merrett010 commented
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