-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
While generating mocks for new methods from hcloud-go 1.37.0 we encountered following error log when running `go generate`: 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' prog.go:14:2: no required module provides package github.com/hetznercloud/cli/internal/hcapi2: go.mod file not found in current directory or any parent directory; see 'go help modules' 2022/11/10 14:52:03 Loading input failed: exit status 1 internal/hcapi2/mock_gen.go:3: running "mockgen": exit status 1 This was solved by moving the mocks into a seperate package.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
package hcapi2_mock | ||
|
||
import ( | ||
"github.com/golang/mock/gomock" | ||
"github.com/hetznercloud/cli/internal/hcapi2" | ||
) | ||
|
||
type MockClient struct { | ||
CertificateClient *MockCertificateClient | ||
DatacenterClient *MockDatacenterClient | ||
FirewallClient *MockFirewallClient | ||
FloatingIPClient *MockFloatingIPClient | ||
PrimaryIPClient *MockPrimaryIPClient | ||
ImageClient *MockImageClient | ||
LocationClient *MockLocationClient | ||
LoadBalancerClient *MockLoadBalancerClient | ||
LoadBalancerTypeClient *MockLoadBalancerTypeClient | ||
NetworkClient *MockNetworkClient | ||
ServerClient *MockServerClient | ||
ServerTypeClient *MockServerTypeClient | ||
SSHKeyClient *MockSSHKeyClient | ||
VolumeClient *MockVolumeClient | ||
ISOClient *MockISOClient | ||
PlacementGroupClient *MockPlacementGroupClient | ||
RDNSClient *MockRDNSClient | ||
} | ||
|
||
func NewMockClient(ctrl *gomock.Controller) *MockClient { | ||
return &MockClient{ | ||
CertificateClient: NewMockCertificateClient(ctrl), | ||
DatacenterClient: NewMockDatacenterClient(ctrl), | ||
FirewallClient: NewMockFirewallClient(ctrl), | ||
FloatingIPClient: NewMockFloatingIPClient(ctrl), | ||
PrimaryIPClient: NewMockPrimaryIPClient(ctrl), | ||
ImageClient: NewMockImageClient(ctrl), | ||
LocationClient: NewMockLocationClient(ctrl), | ||
LoadBalancerClient: NewMockLoadBalancerClient(ctrl), | ||
LoadBalancerTypeClient: NewMockLoadBalancerTypeClient(ctrl), | ||
NetworkClient: NewMockNetworkClient(ctrl), | ||
ServerClient: NewMockServerClient(ctrl), | ||
ServerTypeClient: NewMockServerTypeClient(ctrl), | ||
SSHKeyClient: NewMockSSHKeyClient(ctrl), | ||
VolumeClient: NewMockVolumeClient(ctrl), | ||
ISOClient: NewMockISOClient(ctrl), | ||
PlacementGroupClient: NewMockPlacementGroupClient(ctrl), | ||
RDNSClient: NewMockRDNSClient(ctrl), | ||
} | ||
} | ||
func (c *MockClient) Certificate() hcapi2.CertificateClient { | ||
return c.CertificateClient | ||
} | ||
func (c *MockClient) Datacenter() hcapi2.DatacenterClient { | ||
return c.DatacenterClient | ||
} | ||
|
||
func (c *MockClient) Firewall() hcapi2.FirewallClient { | ||
return c.FirewallClient | ||
} | ||
|
||
func (c *MockClient) FloatingIP() hcapi2.FloatingIPClient { | ||
return c.FloatingIPClient | ||
} | ||
|
||
func (c *MockClient) PrimaryIP() hcapi2.PrimaryIPClient { | ||
return c.PrimaryIPClient | ||
} | ||
|
||
func (c *MockClient) Image() hcapi2.ImageClient { | ||
return c.ImageClient | ||
} | ||
|
||
func (c *MockClient) ISO() hcapi2.ISOClient { | ||
return c.ISOClient | ||
} | ||
|
||
func (c *MockClient) Location() hcapi2.LocationClient { | ||
return c.LocationClient | ||
} | ||
|
||
func (c *MockClient) LoadBalancer() hcapi2.LoadBalancerClient { | ||
return c.LoadBalancerClient | ||
} | ||
|
||
func (c *MockClient) LoadBalancerType() hcapi2.LoadBalancerTypeClient { | ||
return c.LoadBalancerTypeClient | ||
} | ||
|
||
func (c *MockClient) Network() hcapi2.NetworkClient { | ||
return c.NetworkClient | ||
} | ||
|
||
func (c *MockClient) Server() hcapi2.ServerClient { | ||
return c.ServerClient | ||
} | ||
|
||
func (c *MockClient) ServerType() hcapi2.ServerTypeClient { | ||
return c.ServerTypeClient | ||
} | ||
|
||
func (c *MockClient) SSHKey() hcapi2.SSHKeyClient { | ||
return c.SSHKeyClient | ||
} | ||
|
||
func (c *MockClient) Volume() hcapi2.VolumeClient { | ||
return c.VolumeClient | ||
} | ||
func (c *MockClient) RDNS() hcapi2.RDNSClient { | ||
return c.RDNSClient | ||
} | ||
|
||
func (c *MockClient) PlacementGroup() hcapi2.PlacementGroupClient { | ||
return c.PlacementGroupClient | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package hcapi2_mock | ||
|
||
//go:generate mockgen -package hcapi2_mock -destination zz_certificate_client_mock.go github.com/hetznercloud/cli/internal/hcapi2 CertificateClient | ||
//go:generate mockgen -package hcapi2_mock -destination zz_datacenter_client_mock.go github.com/hetznercloud/cli/internal/hcapi2 DatacenterClient | ||
//go:generate mockgen -package hcapi2_mock -destination zz_image_client_mock.go github.com/hetznercloud/cli/internal/hcapi2 ImageClient | ||
//go:generate mockgen -package hcapi2_mock -destination zz_iso_client_mock.go github.com/hetznercloud/cli/internal/hcapi2 ISOClient | ||
//go:generate mockgen -package hcapi2_mock -destination zz_firewall_client_mock.go github.com/hetznercloud/cli/internal/hcapi2 FirewallClient | ||
//go:generate mockgen -package hcapi2_mock -destination zz_floating_ip_client_mock.go github.com/hetznercloud/cli/internal/hcapi2 FloatingIPClient | ||
//go:generate mockgen -package hcapi2_mock -destination zz_primary_ip_client_mock.go github.com/hetznercloud/cli/internal/hcapi2 PrimaryIPClient | ||
//go:generate mockgen -package hcapi2_mock -destination zz_location_client_mock.go github.com/hetznercloud/cli/internal/hcapi2 LocationClient | ||
//go:generate mockgen -package hcapi2_mock -destination zz_loadbalancer_client_mock.go github.com/hetznercloud/cli/internal/hcapi2 LoadBalancerClient | ||
//go:generate mockgen -package hcapi2_mock -destination zz_loadbalancer_type_client_mock.go github.com/hetznercloud/cli/internal/hcapi2 LoadBalancerTypeClient | ||
//go:generate mockgen -package hcapi2_mock -destination zz_network_client_mock.go github.com/hetznercloud/cli/internal/hcapi2 NetworkClient | ||
//go:generate mockgen -package hcapi2_mock -destination zz_server_client_mock.go github.com/hetznercloud/cli/internal/hcapi2 ServerClient | ||
//go:generate mockgen -package hcapi2_mock -destination zz_server_type_client_mock.go github.com/hetznercloud/cli/internal/hcapi2 ServerTypeClient | ||
//go:generate mockgen -package hcapi2_mock -destination zz_ssh_key_client_mock.go github.com/hetznercloud/cli/internal/hcapi2 SSHKeyClient | ||
//go:generate mockgen -package hcapi2_mock -destination zz_volume_client_mock.go github.com/hetznercloud/cli/internal/hcapi2 VolumeClient | ||
//go:generate mockgen -package hcapi2_mock -destination zz_placement_group_client_mock.go github.com/hetznercloud/cli/internal/hcapi2 PlacementGroupClient | ||
//go:generate mockgen -package hcapi2_mock -destination zz_rdns_client_mock.go github.com/hetznercloud/cli/internal/hcapi2 RDNSClient |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.