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

Allow specifying interfaces to be mocked via mocktail argument (vs mock_test.go) #9

Open
tigerinus opened this issue Jan 28, 2023 · 0 comments
Labels
contributor-wanted kind/enhancement a new or improved feature.

Comments

@tigerinus
Copy link

In our project, we use a codegen https://github.com/deepmap/oapi-codegen to generate client under a path ./codegen and this path is ignored in .gitignore (for obvious reason - the code is generated on the fly per build)

The codegen automatiically creates a ClientInterface interface, e.g.

// The interface specification for the client above.
type ClientInterface interface {
	// SubscribeActionWS request
	SubscribeActionWS(ctx context.Context, sourceId SourceID, params *SubscribeActionWSParams, reqEditors ...RequestEditorFn) (*http.Response, error)

	// TriggerAction request with any body
	TriggerActionWithBody(ctx context.Context, sourceId SourceID, name ActionName, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	TriggerAction(ctx context.Context, sourceId SourceID, name ActionName, body TriggerActionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

	// GetActionTypes request
	GetActionTypes(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)

	// RegisterActionTypes request with any body
	RegisterActionTypesWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	RegisterActionTypes(ctx context.Context, body RegisterActionTypesJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

Because ./codegen is ignored, to use mocktail we will have to inconveniently create a mock_test.go as part of the build process before calling mocktail.

It'd be nice to allow passing ClientInterface (together with package name/path) via mocktail arguments. E.g.

mocktail --interface ./codegen#ClientInterface
@ldez ldez added the kind/enhancement a new or improved feature. label Jan 28, 2023
@kevinpollet kevinpollet changed the title [feature request] allow specifying interfaces to be mocked via mocktail argument (vs mock_test.go) Allow specifying interfaces to be mocked via mocktail argument (vs mock_test.go) Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor-wanted kind/enhancement a new or improved feature.
Projects
None yet
Development

No branches or pull requests

3 participants