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

Fix varargs generation #3

Merged
merged 1 commit into from
Oct 16, 2015
Merged

Fix varargs generation #3

merged 1 commit into from
Oct 16, 2015

Conversation

ryanbrainard
Copy link
Owner

This fixes vektra#44 in this fork (will push to main fork later). It still does not work nice for the MockOn convenience methods because things get tricky with converting to interface arrays and it is not clear what the expected behavior should be, so leaving it as is for now.

cc: @fabiokung

@fabiokung
Copy link

👍

@@ -277,6 +278,15 @@ func (g *Generator) genList(list *ast.FieldList, addNames bool) ([]string, []str
return names, types, params
}

func (g *Generator) paramsAsArgNames(params []string) []string {
args := []string{}
r := regexp.MustCompile("(.+?) (\\.{3})?.+")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the space in between the param name and the ellipsis (...) is optional in Go

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mockery normalizes the params up above directly from the AST, so this
should be ok, but I can test it to make sure.

On Friday, October 16, 2015, Fabio Kung notifications@github.com wrote:

In mockery/generator.go
#3 (comment):

@@ -277,6 +278,15 @@ func (g *Generator) genList(list *ast.FieldList, addNames bool) ([]string, []str
return names, types, params
}

+func (g *Generator) paramsAsArgNames(params []string) []string {

  • args := []string{}
  • r := regexp.MustCompile("(.+?) (.{3})?.+")

the space in between the param name and the ellipsis (...) is optional in
Go


Reply to this email directly or view it on GitHub
https://github.com/ryanbrainard/mockery/pull/3/files#r42300369.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried it out, and it does work, but I replaced the regex with direct use of the AST, which is how I really should have done it to begin with: #4

ryanbrainard added a commit that referenced this pull request Oct 16, 2015
@ryanbrainard ryanbrainard merged commit 21267aa into master Oct 16, 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
2 participants