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

Copy slices #33

Merged
merged 4 commits into from Apr 14, 2016
Merged

Copy slices #33

merged 4 commits into from Apr 14, 2016

Conversation

tomwhoiscontrary
Copy link
Contributor

A shot at a solution for issue #30.

The punchline is that if we generate a fake for a method:

    DoASlice([]byte)

It looks like:

func (fake *FakeSomething) DoASlice(arg1 []byte) {
    arg1Copy := make([]byte, len(arg1))
    copy(arg1Copy, arg1)
    fake.doASliceMutex.Lock()
    fake.doASliceArgsForCall = append(fake.doASliceArgsForCall, struct {
        arg1 []byte
    }{arg1Copy})
    fake.doASliceMutex.Unlock()
    if fake.DoASliceStub != nil {
        fake.DoASliceStub(arg1)
    }
}

})

stubFuncCall := &ast.CallExpr{
Fun: stubFunc,
Args: paramValues,
Args: paramValuesToPassToStub,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I absolutely love this change. These variable names were so generic before, and now it makes sense!

@tjarratt
Copy link
Collaborator

This is awesome!

Thanks @tomwhoiscontrary! I appreciate you taking the time to contribute to counterfeiter.

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

Successfully merging this pull request may close these issues.

None yet

2 participants