Skip to content

Error when generating mock client using mockgen package #72

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

Open
parth-gohil opened this issue Jul 25, 2024 · 0 comments
Open

Error when generating mock client using mockgen package #72

parth-gohil opened this issue Jul 25, 2024 · 0 comments

Comments

@parth-gohil
Copy link

Describe the bug
Encountering issues when generating mocks using make generate-mocks

Steps to reproduce
From the root of the package repo use make generate-mocks and you should see the error

What did you expect to see?
I expected the command to sun successfully and see the following

make generate-mocks                                                                                            ─╯
Installing mockgen as it is not present in the system...
/home/pg/go/bin/mockgen
Generating Mocks...
mockgen -package client -destination=./internal/client/mock_client.go "github.com/aws/aws-signer-notation-plugin/internal/client" Interface
Mocks generated successfully.

What did you see instead?
Saw error relating to a package that is referred to by mockgen

make generate-mocks                                                                                            ─╯
Installing mockgen as it is not present in the system...
/home/pg/go/bin/mockgen
Generating Mocks...
mockgen -package client -destination=./internal/client/mock_client.go "github.com/aws/aws-signer-notation-plugin/internal/client" Interface
prog.go:12:2: cannot find module providing package github.com/golang/mock/mockgen/model: import lookup disabled by -mod=vendor
        (Go version in go.mod is at least 1.14 and vendor directory exists.)
prog.go:12:2: cannot find module providing package github.com/golang/mock/mockgen/model: import lookup disabled by -mod=vendor
        (Go version in go.mod is at least 1.14 and vendor directory exists.)
prog.go:14:2: no required module provides package github.com/aws/aws-signer-notation-plugin/internal/client: go.mod file not found in current directory or any parent directory; see 'go help modules'
prog.go:12:2: no required module provides package github.com/golang/mock/mockgen/model: go.mod file not found in current directory or any parent directory; see 'go help modules'
2024/07/25 20:58:48 Loading input failed: exit status 1
make: *** [Makefile:30: generate-mocks] Error 1

What plugin version did you use?
1.0.350

What config did you use?
Config: N/A

Environment
OS: Ubuntu 20.04.6 LTS
notation version : 1.0.0
Notation Go version: go1.20.7
Local Go Version: go1.22.0 linux/amd64

Additional context
I was able to resolve this issue by including an empty import to the internal/client/client.go file by adding _ "github.com/golang/mock/mockgen/model" to the import block. Pritesh found a related issue in the mock package ref. golang/mock#494 . Further reference to the specific comment - golang/mock#494 (comment)

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

1 participant