-
-
Notifications
You must be signed in to change notification settings - Fork 132
Open
Description
In some situations, moq generates mocks that try to import internal 3rd party packages. Minimal example below.
example.go
package app
import (
"context"
pubsub_api "cloud.google.com/go/pubsub"
)
type IPubSubTopic interface {
Exists(ctx context.Context) (bool, error)
Publish(ctx context.Context, msg *pubsub_api.Message) *pubsub_api.PublishResult
}
Here pubsub_api is an explicit alias to the public package.
Generate mock:
moq -out example_mock.go . IPubSubTopic
example_mock.go
// Code generated by moq; DO NOT EDIT.
// github.com/matryer/moq
package app
import (
"cloud.google.com/go/internal/pubsub"
"context"
"sync"
)
// Ensure, that IPubSubTopicMock does implement IPubSubTopic.
// If this is not the case, regenerate this file with moq.
var _ IPubSubTopic = &IPubSubTopicMock{}
But the mock imports the internal pubsub package instead. I couldn't find any way to prevent it.
go version go1.15.6 linux/amd64
moq version: v0.2.3
kpurdon, fleipold, nmarcopo and Code-Hex
Metadata
Metadata
Assignees
Labels
No labels