Skip to content

Commit

Permalink
add strict verify only for non-verified methods (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
ovechkin-dm authored Oct 28, 2024
1 parent 52470ce commit 5450d08
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion registry/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions tests/verify/verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}

0 comments on commit 5450d08

Please sign in to comment.