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

Cannot generate mock for context.Context #53

Closed
wolfgangmeyers opened this issue Feb 12, 2016 · 3 comments
Closed

Cannot generate mock for context.Context #53

wolfgangmeyers opened this issue Feb 12, 2016 · 3 comments

Comments

@wolfgangmeyers
Copy link

Copied this interface into my code and tried to generate a mock, failed with an error:

type Context interface {
    Deadline() (deadline time.Time, ok bool)
    Done() <-chan struct{}
    Err() error
    Value(key interface{}) interface{}
}
$ mockery -name=Context
Generating mock for: Context
Unable to generated mock for 'Context': unable to handle type: &ast.StructType{Struct:1473, Fields:(*ast.FieldList)(0x8206f8ff0), Incomplete:false}
@wolfgangmeyers
Copy link
Author

When I remove the Done() <-chan struct{} the mock generates successfully.

@wolfgangmeyers
Copy link
Author

Temporary workaround - adding the following to the generated mock after commenting out the culprit method (since I'm not using it in my code):

func (_m *MockContext) Done() <-chan struct{} {
    return nil
}

@evanphx
Copy link
Member

evanphx commented Apr 7, 2016

Fixed!

@evanphx evanphx closed this as completed Apr 7, 2016
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