Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Methods with ... params generate broken mocks. #38

Closed
shawnburke opened this issue Aug 4, 2015 · 2 comments
Closed

Methods with ... params generate broken mocks. #38

shawnburke opened this issue Aug 4, 2015 · 2 comments

Comments

@shawnburke
Copy link
Contributor

This is a regression sometime since SHA a43d734f241595. Not sure exactly when.

The following interface will generate a mock that doesn't compile:

 type MyInterface interface {
   WriteItems(uuid string, values ...string) error
 }

The old "working" code generated code that probably wasn't mockable, but it wasn't blocking.

This generates:

func (_m *MyInterface) WriteItems(uuid string, values ...string) error {
ret := _m.Called(uuid, values)
var r0 error
if rf, ok := ret.Get(0).(func(string, ...string) error); ok {
    r0 = rf(uuid, values)
} else {
    r0 = ret.Error(0)
    }
return r0
}

Which results in:

 mocks/MyInterface.go:14: cannot use values (type []string) as type string in argument to rf

I think Line 14 needs to be:

        r0 = rf(uuid, values...)
shawnburke pushed a commit to shawnburke/mockery that referenced this issue Aug 4, 2015
@shawnburke
Copy link
Contributor Author

Fix PR here

evanphx added a commit that referenced this issue Aug 4, 2015
Fix for Broken ... params (Issue #38)
@evanphx
Copy link
Member

evanphx commented Aug 4, 2015

Fix merged! Thanks!

@evanphx evanphx closed this as completed Aug 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants