Skip to content

Error when generating mock client using mockgen package #72

@parth-gohil

Description

@parth-gohil

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions