vektra / mockery

A mock code autogenerator for Go
https://vektra.github.io/mockery/
BSD 3-Clause "New" or "Revised" License
6.08k stars 408 forks source link

RunAndReturn on functions without return value should not be silently skipped #823

Open RouquinBlanc opened 2 weeks ago

RouquinBlanc commented 2 weeks ago

PLEASE READ

DO NOT submit tickets without first using the latest version of Go, clearing your local golang package cache, and re-building mockery using the latest Go version and the latest version of mockery. Please provide evidence this has been done in your issue. Failure to provide this evidence will likely result in your issue being closed.

Description

Following discussions on #782, it would be better to have RunAndReturn run correctly on functions not returning a value or entirely removed. Opening this issue for tracking the fix

Mockery Version

v2.46.2

Go Version

1.23

NOTE: Please upgrade to the latest golang version before submitting tickets!

Installation Method

Steps to Reproduce


myMock.EXPECT().MyFuncWithReturn().RunAndReturn(func() {
    // this is not called
})

Expected Behavior

Using RunAndReturn on a mocked function which does not return any value should either:

Actual Behavior

The call to the inner function is skipped

LandonTClipp commented 2 weeks ago

Yes absolutely! We need to get this fixed.