From 5450d08b42502da4f55427f410304f9fde0d9763 Mon Sep 17 00:00:00 2001 From: ovechkin-dm Date: Mon, 28 Oct 2024 16:06:51 +0100 Subject: [PATCH] add strict verify only for non-verified methods (#84) --- registry/handler.go | 4 +++- tests/verify/verify_test.go | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/registry/handler.go b/registry/handler.go index fb66885..210c1cd 100644 --- a/registry/handler.go +++ b/registry/handler.go @@ -352,7 +352,9 @@ func (h *invocationHandler) TearDown() { if h.ctx.cfg.StrictVerify { for _, m := range h.methods { for _, mm := range m.methodMatches { - mm.verifiers = append(mm.verifiers, matchers.AtLeastOnce()) + if len(mm.verifiers) == 0 { + mm.verifiers = append(mm.verifiers, matchers.AtLeastOnce()) + } } } h.VerifyNoMoreInteractions(true) diff --git a/tests/verify/verify_test.go b/tests/verify/verify_test.go index 9ef9bb5..826cba5 100644 --- a/tests/verify/verify_test.go +++ b/tests/verify/verify_test.go @@ -187,3 +187,9 @@ func TestStrictVerifyUnverifiedStub(t *testing.T) { r.TriggerCleanup() r.AssertError() } + +func TestVerifyNeverInReturner(t *testing.T) { + SetUp(t, mockopts.StrictVerify()) + m := Mock[iface]() + WhenSingle(m.Foo(12)).Verify(Never()) +}