vektra / mockery

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

Fix bug when last argument is a function with multiple return values #774

Closed LandonTClipp closed 5 months ago

LandonTClipp commented 5 months ago

Description

There are two bugs fixed in this commit:

  1. As noted in issue #766, mockery failed to generate a mock because it incorrectly considered the return values themselves to be variadic, which is impossible. The fix is to always consider return tuples non-variadic.
  2. The .EXPECT() struct had an incorrect signature when the argument was a variadic function. The reason was because it triggered off the presence of "..." in the type string instead of triggering off the variadic-ness of the outer function. The fix was to simply use the variadic flag to determine if the last argument should be variadic.

Fixes #766

Type of change

Version of Golang used when building/testing: