Mocking function from imported package
Svampen opened this issue · 3 comments
Hi
I'm trying to figure out if mockcompose supports my scenario.
Here is a cut out of the package my code is using:
package secret
import (
"regexp"
)
type SecretData struct {
Data []byte
Name string
}
func GetSecrets(projectId string, secretsRegexp *regexp.Regexp) ([]SecretData, error) {
...
}
Here is a cut out of my code:
package foo
import (
"github.com/.../secret"
"regexp"
)
func Bar() error {
secretsData, err := secret.GetSecrets("projectId", regexp.MustCompile(`-\w{4}$`))
...
}
I'm trying to mock secret.GetSecrets by using mockcompose and I tried //go:generate mockcompose -v -n mockSecret -p github.com/.../secret -mock GetSecrets
but the generated file will then be missing import for regexp and don't have the SecretData struct so it doesn't compile.
I could fixed that after generating the file but I don't think that's the point with mockcompose 😃
Any help in how I should continue (if currently possible) would be very much appreciate as I really like your package, keep up the good work on it!
I could fixed that after generating the file but I don't think that's the point with mockcompose
Yeah, this will against the point of mockcompose.
Why did you close this issue? I'll check to see if I can fix it