diff --git a/.mockery.yaml b/.mockery.yaml new file mode 100644 index 0000000..9e16473 --- /dev/null +++ b/.mockery.yaml @@ -0,0 +1,8 @@ +--- +all: true +disable-version-string: true +outpkg: 'mocks' +packages: + go.woodpecker-ci.org/autoscaler/providers/hetznercloud/hcapi: + config: + dir: 'providers/hetznercloud/{{.PackageName}}/mocks' diff --git a/Makefile b/Makefile index 5d9dd5e..b9c8dbf 100644 --- a/Makefile +++ b/Makefile @@ -75,6 +75,9 @@ install-tools: ## Install development tools hash gofumpt > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ go install mvdan.cc/gofumpt@latest; \ fi ; \ + hash mockery > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ + go install github.com/vektra/mockery/v2@latest; \ + fi ; \ ##@ Test @@ -91,6 +94,10 @@ test-autoscaler: ## Test autoscaler code .PHONY: test test: test-autoscaler ## Run all tests +.PHONY: generate +generate: + mockery + ##@ Build build: diff --git a/engine/stringmaps_test.go b/engine/stringmaps_test.go index 58afad5..171fdaa 100644 --- a/engine/stringmaps_test.go +++ b/engine/stringmaps_test.go @@ -37,17 +37,17 @@ func TestSliceToMap(t *testing.T) { }, } - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - actual, err := SliceToMap(tc.input, tc.del) - if tc.wantErr != nil { + for _, tt := range testCases { + t.Run(tt.name, func(t *testing.T) { + actual, err := SliceToMap(tt.input, tt.del) + if tt.wantErr != nil { assert.Error(t, err) return } assert.NoError(t, err) - assert.Equal(t, tc.want, actual) + assert.Equal(t, tt.want, actual) }) } } @@ -85,10 +85,10 @@ func TestMergeMaps(t *testing.T) { }, } - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - merged := MergeMaps(tc.m1, tc.m2) - assert.Equal(t, tc.want, merged) + for _, tt := range testCases { + t.Run(tt.name, func(t *testing.T) { + merged := MergeMaps(tt.m1, tt.m2) + assert.Equal(t, tt.want, merged) }) } } diff --git a/go.mod b/go.mod index 73292b8..7ecae61 100644 --- a/go.mod +++ b/go.mod @@ -32,6 +32,7 @@ require ( github.com/prometheus/common v0.54.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect + github.com/stretchr/objx v0.5.2 // indirect github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect golang.org/x/sys v0.21.0 // indirect golang.org/x/text v0.16.0 // indirect diff --git a/go.sum b/go.sum index a9d5cd6..9f23c94 100644 --- a/go.sum +++ b/go.sum @@ -50,6 +50,8 @@ github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/urfave/cli/v2 v2.27.2 h1:6e0H+AkS+zDckwPCUrZkKX38mRaau4nL2uipkJpbkcI= diff --git a/providers/hetznercloud/hcapi/api.go b/providers/hetznercloud/hcapi/api.go new file mode 100644 index 0000000..e1052c9 --- /dev/null +++ b/providers/hetznercloud/hcapi/api.go @@ -0,0 +1,132 @@ +package hcapi + +import ( + "github.com/hetznercloud/hcloud-go/v2/hcloud" +) + +type Client interface { + Firewall() FirewallClient + Image() ImageClient + Network() NetworkClient + Server() ServerClient + ServerType() ServerTypeClient + SSHKey() SSHKeyClient +} + +type client struct { + client *hcloud.Client +} + +type ServerTypeClient interface { + hcloud.IServerTypeClient +} + +type serverTypeClient struct { + hcloud.IServerTypeClient +} + +type ImageClient interface { + hcloud.IImageClient +} + +type imageClient struct { + hcloud.IImageClient +} + +type SSHKeyClient interface { + hcloud.ISSHKeyClient +} + +type sshKeyClient struct { + hcloud.ISSHKeyClient +} + +type ServerClient interface { + hcloud.IServerClient +} + +type serverClient struct { + hcloud.IServerClient +} + +type NetworkClient interface { + hcloud.INetworkClient +} + +type networkClient struct { + hcloud.INetworkClient +} + +type FirewallClient interface { + hcloud.IFirewallClient +} + +type firewallClient struct { + hcloud.IFirewallClient +} + +func NewClient(opts ...hcloud.ClientOption) Client { + return &client{ + client: hcloud.NewClient(opts...), + } +} + +func NewServerTypeClient(client hcloud.IServerTypeClient) ServerTypeClient { + return &serverTypeClient{ + IServerTypeClient: client, + } +} + +func (c *client) ServerType() ServerTypeClient { + return NewServerTypeClient(&c.client.ServerType) +} + +func NewImageClient(client hcloud.IImageClient) ImageClient { + return &imageClient{ + IImageClient: client, + } +} + +func (c *client) Image() ImageClient { + return NewImageClient(&c.client.Image) +} + +func NewSSHKeyClient(client hcloud.ISSHKeyClient) SSHKeyClient { + return &sshKeyClient{ + ISSHKeyClient: client, + } +} + +func (c *client) SSHKey() SSHKeyClient { + return NewSSHKeyClient(&c.client.SSHKey) +} + +func NewServerClient(client *hcloud.ServerClient) ServerClient { + return &serverClient{ + IServerClient: client, + } +} + +func (c *client) Server() ServerClient { + return NewServerClient(&c.client.Server) +} + +func NewFirewallClient(client hcloud.IFirewallClient) FirewallClient { + return &firewallClient{ + IFirewallClient: client, + } +} + +func (c *client) Firewall() FirewallClient { + return NewFirewallClient(&c.client.Firewall) +} + +func NewNetworkClient(client hcloud.INetworkClient) NetworkClient { + return &networkClient{ + INetworkClient: client, + } +} + +func (c *client) Network() NetworkClient { + return NewNetworkClient(&c.client.Network) +} diff --git a/providers/hetznercloud/hcapi/mocks/mock_Client.go b/providers/hetznercloud/hcapi/mocks/mock_Client.go new file mode 100644 index 0000000..ad4cb60 --- /dev/null +++ b/providers/hetznercloud/hcapi/mocks/mock_Client.go @@ -0,0 +1,317 @@ +// Code generated by mockery. DO NOT EDIT. + +package mocks + +import ( + mock "github.com/stretchr/testify/mock" + hcapi "go.woodpecker-ci.org/autoscaler/providers/hetznercloud/hcapi" +) + +// MockClient is an autogenerated mock type for the Client type +type MockClient struct { + mock.Mock +} + +type MockClient_Expecter struct { + mock *mock.Mock +} + +func (_m *MockClient) EXPECT() *MockClient_Expecter { + return &MockClient_Expecter{mock: &_m.Mock} +} + +// Firewall provides a mock function with given fields: +func (_m *MockClient) Firewall() hcapi.FirewallClient { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Firewall") + } + + var r0 hcapi.FirewallClient + if rf, ok := ret.Get(0).(func() hcapi.FirewallClient); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(hcapi.FirewallClient) + } + } + + return r0 +} + +// MockClient_Firewall_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Firewall' +type MockClient_Firewall_Call struct { + *mock.Call +} + +// Firewall is a helper method to define mock.On call +func (_e *MockClient_Expecter) Firewall() *MockClient_Firewall_Call { + return &MockClient_Firewall_Call{Call: _e.mock.On("Firewall")} +} + +func (_c *MockClient_Firewall_Call) Run(run func()) *MockClient_Firewall_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockClient_Firewall_Call) Return(_a0 hcapi.FirewallClient) *MockClient_Firewall_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockClient_Firewall_Call) RunAndReturn(run func() hcapi.FirewallClient) *MockClient_Firewall_Call { + _c.Call.Return(run) + return _c +} + +// Image provides a mock function with given fields: +func (_m *MockClient) Image() hcapi.ImageClient { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Image") + } + + var r0 hcapi.ImageClient + if rf, ok := ret.Get(0).(func() hcapi.ImageClient); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(hcapi.ImageClient) + } + } + + return r0 +} + +// MockClient_Image_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Image' +type MockClient_Image_Call struct { + *mock.Call +} + +// Image is a helper method to define mock.On call +func (_e *MockClient_Expecter) Image() *MockClient_Image_Call { + return &MockClient_Image_Call{Call: _e.mock.On("Image")} +} + +func (_c *MockClient_Image_Call) Run(run func()) *MockClient_Image_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockClient_Image_Call) Return(_a0 hcapi.ImageClient) *MockClient_Image_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockClient_Image_Call) RunAndReturn(run func() hcapi.ImageClient) *MockClient_Image_Call { + _c.Call.Return(run) + return _c +} + +// Network provides a mock function with given fields: +func (_m *MockClient) Network() hcapi.NetworkClient { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Network") + } + + var r0 hcapi.NetworkClient + if rf, ok := ret.Get(0).(func() hcapi.NetworkClient); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(hcapi.NetworkClient) + } + } + + return r0 +} + +// MockClient_Network_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Network' +type MockClient_Network_Call struct { + *mock.Call +} + +// Network is a helper method to define mock.On call +func (_e *MockClient_Expecter) Network() *MockClient_Network_Call { + return &MockClient_Network_Call{Call: _e.mock.On("Network")} +} + +func (_c *MockClient_Network_Call) Run(run func()) *MockClient_Network_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockClient_Network_Call) Return(_a0 hcapi.NetworkClient) *MockClient_Network_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockClient_Network_Call) RunAndReturn(run func() hcapi.NetworkClient) *MockClient_Network_Call { + _c.Call.Return(run) + return _c +} + +// SSHKey provides a mock function with given fields: +func (_m *MockClient) SSHKey() hcapi.SSHKeyClient { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for SSHKey") + } + + var r0 hcapi.SSHKeyClient + if rf, ok := ret.Get(0).(func() hcapi.SSHKeyClient); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(hcapi.SSHKeyClient) + } + } + + return r0 +} + +// MockClient_SSHKey_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SSHKey' +type MockClient_SSHKey_Call struct { + *mock.Call +} + +// SSHKey is a helper method to define mock.On call +func (_e *MockClient_Expecter) SSHKey() *MockClient_SSHKey_Call { + return &MockClient_SSHKey_Call{Call: _e.mock.On("SSHKey")} +} + +func (_c *MockClient_SSHKey_Call) Run(run func()) *MockClient_SSHKey_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockClient_SSHKey_Call) Return(_a0 hcapi.SSHKeyClient) *MockClient_SSHKey_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockClient_SSHKey_Call) RunAndReturn(run func() hcapi.SSHKeyClient) *MockClient_SSHKey_Call { + _c.Call.Return(run) + return _c +} + +// Server provides a mock function with given fields: +func (_m *MockClient) Server() hcapi.ServerClient { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Server") + } + + var r0 hcapi.ServerClient + if rf, ok := ret.Get(0).(func() hcapi.ServerClient); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(hcapi.ServerClient) + } + } + + return r0 +} + +// MockClient_Server_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Server' +type MockClient_Server_Call struct { + *mock.Call +} + +// Server is a helper method to define mock.On call +func (_e *MockClient_Expecter) Server() *MockClient_Server_Call { + return &MockClient_Server_Call{Call: _e.mock.On("Server")} +} + +func (_c *MockClient_Server_Call) Run(run func()) *MockClient_Server_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockClient_Server_Call) Return(_a0 hcapi.ServerClient) *MockClient_Server_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockClient_Server_Call) RunAndReturn(run func() hcapi.ServerClient) *MockClient_Server_Call { + _c.Call.Return(run) + return _c +} + +// ServerType provides a mock function with given fields: +func (_m *MockClient) ServerType() hcapi.ServerTypeClient { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for ServerType") + } + + var r0 hcapi.ServerTypeClient + if rf, ok := ret.Get(0).(func() hcapi.ServerTypeClient); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(hcapi.ServerTypeClient) + } + } + + return r0 +} + +// MockClient_ServerType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ServerType' +type MockClient_ServerType_Call struct { + *mock.Call +} + +// ServerType is a helper method to define mock.On call +func (_e *MockClient_Expecter) ServerType() *MockClient_ServerType_Call { + return &MockClient_ServerType_Call{Call: _e.mock.On("ServerType")} +} + +func (_c *MockClient_ServerType_Call) Run(run func()) *MockClient_ServerType_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockClient_ServerType_Call) Return(_a0 hcapi.ServerTypeClient) *MockClient_ServerType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockClient_ServerType_Call) RunAndReturn(run func() hcapi.ServerTypeClient) *MockClient_ServerType_Call { + _c.Call.Return(run) + return _c +} + +// NewMockClient creates a new instance of MockClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockClient(t interface { + mock.TestingT + Cleanup(func()) +}) *MockClient { + mock := &MockClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/providers/hetznercloud/hcapi/mocks/mock_FirewallClient.go b/providers/hetznercloud/hcapi/mocks/mock_FirewallClient.go new file mode 100644 index 0000000..90e4b1b --- /dev/null +++ b/providers/hetznercloud/hcapi/mocks/mock_FirewallClient.go @@ -0,0 +1,828 @@ +// Code generated by mockery. DO NOT EDIT. + +package mocks + +import ( + context "context" + + hcloud "github.com/hetznercloud/hcloud-go/v2/hcloud" + + mock "github.com/stretchr/testify/mock" +) + +// MockFirewallClient is an autogenerated mock type for the FirewallClient type +type MockFirewallClient struct { + mock.Mock +} + +type MockFirewallClient_Expecter struct { + mock *mock.Mock +} + +func (_m *MockFirewallClient) EXPECT() *MockFirewallClient_Expecter { + return &MockFirewallClient_Expecter{mock: &_m.Mock} +} + +// All provides a mock function with given fields: ctx +func (_m *MockFirewallClient) All(ctx context.Context) ([]*hcloud.Firewall, error) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for All") + } + + var r0 []*hcloud.Firewall + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) ([]*hcloud.Firewall, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) []*hcloud.Firewall); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*hcloud.Firewall) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockFirewallClient_All_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'All' +type MockFirewallClient_All_Call struct { + *mock.Call +} + +// All is a helper method to define mock.On call +// - ctx context.Context +func (_e *MockFirewallClient_Expecter) All(ctx interface{}) *MockFirewallClient_All_Call { + return &MockFirewallClient_All_Call{Call: _e.mock.On("All", ctx)} +} + +func (_c *MockFirewallClient_All_Call) Run(run func(ctx context.Context)) *MockFirewallClient_All_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *MockFirewallClient_All_Call) Return(_a0 []*hcloud.Firewall, _a1 error) *MockFirewallClient_All_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockFirewallClient_All_Call) RunAndReturn(run func(context.Context) ([]*hcloud.Firewall, error)) *MockFirewallClient_All_Call { + _c.Call.Return(run) + return _c +} + +// AllWithOpts provides a mock function with given fields: ctx, opts +func (_m *MockFirewallClient) AllWithOpts(ctx context.Context, opts hcloud.FirewallListOpts) ([]*hcloud.Firewall, error) { + ret := _m.Called(ctx, opts) + + if len(ret) == 0 { + panic("no return value specified for AllWithOpts") + } + + var r0 []*hcloud.Firewall + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, hcloud.FirewallListOpts) ([]*hcloud.Firewall, error)); ok { + return rf(ctx, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, hcloud.FirewallListOpts) []*hcloud.Firewall); ok { + r0 = rf(ctx, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*hcloud.Firewall) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, hcloud.FirewallListOpts) error); ok { + r1 = rf(ctx, opts) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockFirewallClient_AllWithOpts_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AllWithOpts' +type MockFirewallClient_AllWithOpts_Call struct { + *mock.Call +} + +// AllWithOpts is a helper method to define mock.On call +// - ctx context.Context +// - opts hcloud.FirewallListOpts +func (_e *MockFirewallClient_Expecter) AllWithOpts(ctx interface{}, opts interface{}) *MockFirewallClient_AllWithOpts_Call { + return &MockFirewallClient_AllWithOpts_Call{Call: _e.mock.On("AllWithOpts", ctx, opts)} +} + +func (_c *MockFirewallClient_AllWithOpts_Call) Run(run func(ctx context.Context, opts hcloud.FirewallListOpts)) *MockFirewallClient_AllWithOpts_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(hcloud.FirewallListOpts)) + }) + return _c +} + +func (_c *MockFirewallClient_AllWithOpts_Call) Return(_a0 []*hcloud.Firewall, _a1 error) *MockFirewallClient_AllWithOpts_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockFirewallClient_AllWithOpts_Call) RunAndReturn(run func(context.Context, hcloud.FirewallListOpts) ([]*hcloud.Firewall, error)) *MockFirewallClient_AllWithOpts_Call { + _c.Call.Return(run) + return _c +} + +// ApplyResources provides a mock function with given fields: ctx, firewall, resources +func (_m *MockFirewallClient) ApplyResources(ctx context.Context, firewall *hcloud.Firewall, resources []hcloud.FirewallResource) ([]*hcloud.Action, *hcloud.Response, error) { + ret := _m.Called(ctx, firewall, resources) + + if len(ret) == 0 { + panic("no return value specified for ApplyResources") + } + + var r0 []*hcloud.Action + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Firewall, []hcloud.FirewallResource) ([]*hcloud.Action, *hcloud.Response, error)); ok { + return rf(ctx, firewall, resources) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Firewall, []hcloud.FirewallResource) []*hcloud.Action); ok { + r0 = rf(ctx, firewall, resources) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*hcloud.Action) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Firewall, []hcloud.FirewallResource) *hcloud.Response); ok { + r1 = rf(ctx, firewall, resources) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Firewall, []hcloud.FirewallResource) error); ok { + r2 = rf(ctx, firewall, resources) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockFirewallClient_ApplyResources_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ApplyResources' +type MockFirewallClient_ApplyResources_Call struct { + *mock.Call +} + +// ApplyResources is a helper method to define mock.On call +// - ctx context.Context +// - firewall *hcloud.Firewall +// - resources []hcloud.FirewallResource +func (_e *MockFirewallClient_Expecter) ApplyResources(ctx interface{}, firewall interface{}, resources interface{}) *MockFirewallClient_ApplyResources_Call { + return &MockFirewallClient_ApplyResources_Call{Call: _e.mock.On("ApplyResources", ctx, firewall, resources)} +} + +func (_c *MockFirewallClient_ApplyResources_Call) Run(run func(ctx context.Context, firewall *hcloud.Firewall, resources []hcloud.FirewallResource)) *MockFirewallClient_ApplyResources_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Firewall), args[2].([]hcloud.FirewallResource)) + }) + return _c +} + +func (_c *MockFirewallClient_ApplyResources_Call) Return(_a0 []*hcloud.Action, _a1 *hcloud.Response, _a2 error) *MockFirewallClient_ApplyResources_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockFirewallClient_ApplyResources_Call) RunAndReturn(run func(context.Context, *hcloud.Firewall, []hcloud.FirewallResource) ([]*hcloud.Action, *hcloud.Response, error)) *MockFirewallClient_ApplyResources_Call { + _c.Call.Return(run) + return _c +} + +// Create provides a mock function with given fields: ctx, opts +func (_m *MockFirewallClient) Create(ctx context.Context, opts hcloud.FirewallCreateOpts) (hcloud.FirewallCreateResult, *hcloud.Response, error) { + ret := _m.Called(ctx, opts) + + if len(ret) == 0 { + panic("no return value specified for Create") + } + + var r0 hcloud.FirewallCreateResult + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, hcloud.FirewallCreateOpts) (hcloud.FirewallCreateResult, *hcloud.Response, error)); ok { + return rf(ctx, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, hcloud.FirewallCreateOpts) hcloud.FirewallCreateResult); ok { + r0 = rf(ctx, opts) + } else { + r0 = ret.Get(0).(hcloud.FirewallCreateResult) + } + + if rf, ok := ret.Get(1).(func(context.Context, hcloud.FirewallCreateOpts) *hcloud.Response); ok { + r1 = rf(ctx, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, hcloud.FirewallCreateOpts) error); ok { + r2 = rf(ctx, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockFirewallClient_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type MockFirewallClient_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - opts hcloud.FirewallCreateOpts +func (_e *MockFirewallClient_Expecter) Create(ctx interface{}, opts interface{}) *MockFirewallClient_Create_Call { + return &MockFirewallClient_Create_Call{Call: _e.mock.On("Create", ctx, opts)} +} + +func (_c *MockFirewallClient_Create_Call) Run(run func(ctx context.Context, opts hcloud.FirewallCreateOpts)) *MockFirewallClient_Create_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(hcloud.FirewallCreateOpts)) + }) + return _c +} + +func (_c *MockFirewallClient_Create_Call) Return(_a0 hcloud.FirewallCreateResult, _a1 *hcloud.Response, _a2 error) *MockFirewallClient_Create_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockFirewallClient_Create_Call) RunAndReturn(run func(context.Context, hcloud.FirewallCreateOpts) (hcloud.FirewallCreateResult, *hcloud.Response, error)) *MockFirewallClient_Create_Call { + _c.Call.Return(run) + return _c +} + +// Delete provides a mock function with given fields: ctx, firewall +func (_m *MockFirewallClient) Delete(ctx context.Context, firewall *hcloud.Firewall) (*hcloud.Response, error) { + ret := _m.Called(ctx, firewall) + + if len(ret) == 0 { + panic("no return value specified for Delete") + } + + var r0 *hcloud.Response + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Firewall) (*hcloud.Response, error)); ok { + return rf(ctx, firewall) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Firewall) *hcloud.Response); ok { + r0 = rf(ctx, firewall) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Firewall) error); ok { + r1 = rf(ctx, firewall) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockFirewallClient_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' +type MockFirewallClient_Delete_Call struct { + *mock.Call +} + +// Delete is a helper method to define mock.On call +// - ctx context.Context +// - firewall *hcloud.Firewall +func (_e *MockFirewallClient_Expecter) Delete(ctx interface{}, firewall interface{}) *MockFirewallClient_Delete_Call { + return &MockFirewallClient_Delete_Call{Call: _e.mock.On("Delete", ctx, firewall)} +} + +func (_c *MockFirewallClient_Delete_Call) Run(run func(ctx context.Context, firewall *hcloud.Firewall)) *MockFirewallClient_Delete_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Firewall)) + }) + return _c +} + +func (_c *MockFirewallClient_Delete_Call) Return(_a0 *hcloud.Response, _a1 error) *MockFirewallClient_Delete_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockFirewallClient_Delete_Call) RunAndReturn(run func(context.Context, *hcloud.Firewall) (*hcloud.Response, error)) *MockFirewallClient_Delete_Call { + _c.Call.Return(run) + return _c +} + +// Get provides a mock function with given fields: ctx, idOrName +func (_m *MockFirewallClient) Get(ctx context.Context, idOrName string) (*hcloud.Firewall, *hcloud.Response, error) { + ret := _m.Called(ctx, idOrName) + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 *hcloud.Firewall + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*hcloud.Firewall, *hcloud.Response, error)); ok { + return rf(ctx, idOrName) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *hcloud.Firewall); ok { + r0 = rf(ctx, idOrName) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Firewall) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) *hcloud.Response); ok { + r1 = rf(ctx, idOrName) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, string) error); ok { + r2 = rf(ctx, idOrName) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockFirewallClient_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type MockFirewallClient_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +// - ctx context.Context +// - idOrName string +func (_e *MockFirewallClient_Expecter) Get(ctx interface{}, idOrName interface{}) *MockFirewallClient_Get_Call { + return &MockFirewallClient_Get_Call{Call: _e.mock.On("Get", ctx, idOrName)} +} + +func (_c *MockFirewallClient_Get_Call) Run(run func(ctx context.Context, idOrName string)) *MockFirewallClient_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockFirewallClient_Get_Call) Return(_a0 *hcloud.Firewall, _a1 *hcloud.Response, _a2 error) *MockFirewallClient_Get_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockFirewallClient_Get_Call) RunAndReturn(run func(context.Context, string) (*hcloud.Firewall, *hcloud.Response, error)) *MockFirewallClient_Get_Call { + _c.Call.Return(run) + return _c +} + +// GetByID provides a mock function with given fields: ctx, id +func (_m *MockFirewallClient) GetByID(ctx context.Context, id int64) (*hcloud.Firewall, *hcloud.Response, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for GetByID") + } + + var r0 *hcloud.Firewall + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, int64) (*hcloud.Firewall, *hcloud.Response, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, int64) *hcloud.Firewall); ok { + r0 = rf(ctx, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Firewall) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, int64) *hcloud.Response); ok { + r1 = rf(ctx, id) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, int64) error); ok { + r2 = rf(ctx, id) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockFirewallClient_GetByID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByID' +type MockFirewallClient_GetByID_Call struct { + *mock.Call +} + +// GetByID is a helper method to define mock.On call +// - ctx context.Context +// - id int64 +func (_e *MockFirewallClient_Expecter) GetByID(ctx interface{}, id interface{}) *MockFirewallClient_GetByID_Call { + return &MockFirewallClient_GetByID_Call{Call: _e.mock.On("GetByID", ctx, id)} +} + +func (_c *MockFirewallClient_GetByID_Call) Run(run func(ctx context.Context, id int64)) *MockFirewallClient_GetByID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(int64)) + }) + return _c +} + +func (_c *MockFirewallClient_GetByID_Call) Return(_a0 *hcloud.Firewall, _a1 *hcloud.Response, _a2 error) *MockFirewallClient_GetByID_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockFirewallClient_GetByID_Call) RunAndReturn(run func(context.Context, int64) (*hcloud.Firewall, *hcloud.Response, error)) *MockFirewallClient_GetByID_Call { + _c.Call.Return(run) + return _c +} + +// GetByName provides a mock function with given fields: ctx, name +func (_m *MockFirewallClient) GetByName(ctx context.Context, name string) (*hcloud.Firewall, *hcloud.Response, error) { + ret := _m.Called(ctx, name) + + if len(ret) == 0 { + panic("no return value specified for GetByName") + } + + var r0 *hcloud.Firewall + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*hcloud.Firewall, *hcloud.Response, error)); ok { + return rf(ctx, name) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *hcloud.Firewall); ok { + r0 = rf(ctx, name) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Firewall) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) *hcloud.Response); ok { + r1 = rf(ctx, name) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, string) error); ok { + r2 = rf(ctx, name) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockFirewallClient_GetByName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByName' +type MockFirewallClient_GetByName_Call struct { + *mock.Call +} + +// GetByName is a helper method to define mock.On call +// - ctx context.Context +// - name string +func (_e *MockFirewallClient_Expecter) GetByName(ctx interface{}, name interface{}) *MockFirewallClient_GetByName_Call { + return &MockFirewallClient_GetByName_Call{Call: _e.mock.On("GetByName", ctx, name)} +} + +func (_c *MockFirewallClient_GetByName_Call) Run(run func(ctx context.Context, name string)) *MockFirewallClient_GetByName_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockFirewallClient_GetByName_Call) Return(_a0 *hcloud.Firewall, _a1 *hcloud.Response, _a2 error) *MockFirewallClient_GetByName_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockFirewallClient_GetByName_Call) RunAndReturn(run func(context.Context, string) (*hcloud.Firewall, *hcloud.Response, error)) *MockFirewallClient_GetByName_Call { + _c.Call.Return(run) + return _c +} + +// List provides a mock function with given fields: ctx, opts +func (_m *MockFirewallClient) List(ctx context.Context, opts hcloud.FirewallListOpts) ([]*hcloud.Firewall, *hcloud.Response, error) { + ret := _m.Called(ctx, opts) + + if len(ret) == 0 { + panic("no return value specified for List") + } + + var r0 []*hcloud.Firewall + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, hcloud.FirewallListOpts) ([]*hcloud.Firewall, *hcloud.Response, error)); ok { + return rf(ctx, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, hcloud.FirewallListOpts) []*hcloud.Firewall); ok { + r0 = rf(ctx, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*hcloud.Firewall) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, hcloud.FirewallListOpts) *hcloud.Response); ok { + r1 = rf(ctx, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, hcloud.FirewallListOpts) error); ok { + r2 = rf(ctx, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockFirewallClient_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' +type MockFirewallClient_List_Call struct { + *mock.Call +} + +// List is a helper method to define mock.On call +// - ctx context.Context +// - opts hcloud.FirewallListOpts +func (_e *MockFirewallClient_Expecter) List(ctx interface{}, opts interface{}) *MockFirewallClient_List_Call { + return &MockFirewallClient_List_Call{Call: _e.mock.On("List", ctx, opts)} +} + +func (_c *MockFirewallClient_List_Call) Run(run func(ctx context.Context, opts hcloud.FirewallListOpts)) *MockFirewallClient_List_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(hcloud.FirewallListOpts)) + }) + return _c +} + +func (_c *MockFirewallClient_List_Call) Return(_a0 []*hcloud.Firewall, _a1 *hcloud.Response, _a2 error) *MockFirewallClient_List_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockFirewallClient_List_Call) RunAndReturn(run func(context.Context, hcloud.FirewallListOpts) ([]*hcloud.Firewall, *hcloud.Response, error)) *MockFirewallClient_List_Call { + _c.Call.Return(run) + return _c +} + +// RemoveResources provides a mock function with given fields: ctx, firewall, resources +func (_m *MockFirewallClient) RemoveResources(ctx context.Context, firewall *hcloud.Firewall, resources []hcloud.FirewallResource) ([]*hcloud.Action, *hcloud.Response, error) { + ret := _m.Called(ctx, firewall, resources) + + if len(ret) == 0 { + panic("no return value specified for RemoveResources") + } + + var r0 []*hcloud.Action + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Firewall, []hcloud.FirewallResource) ([]*hcloud.Action, *hcloud.Response, error)); ok { + return rf(ctx, firewall, resources) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Firewall, []hcloud.FirewallResource) []*hcloud.Action); ok { + r0 = rf(ctx, firewall, resources) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*hcloud.Action) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Firewall, []hcloud.FirewallResource) *hcloud.Response); ok { + r1 = rf(ctx, firewall, resources) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Firewall, []hcloud.FirewallResource) error); ok { + r2 = rf(ctx, firewall, resources) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockFirewallClient_RemoveResources_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveResources' +type MockFirewallClient_RemoveResources_Call struct { + *mock.Call +} + +// RemoveResources is a helper method to define mock.On call +// - ctx context.Context +// - firewall *hcloud.Firewall +// - resources []hcloud.FirewallResource +func (_e *MockFirewallClient_Expecter) RemoveResources(ctx interface{}, firewall interface{}, resources interface{}) *MockFirewallClient_RemoveResources_Call { + return &MockFirewallClient_RemoveResources_Call{Call: _e.mock.On("RemoveResources", ctx, firewall, resources)} +} + +func (_c *MockFirewallClient_RemoveResources_Call) Run(run func(ctx context.Context, firewall *hcloud.Firewall, resources []hcloud.FirewallResource)) *MockFirewallClient_RemoveResources_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Firewall), args[2].([]hcloud.FirewallResource)) + }) + return _c +} + +func (_c *MockFirewallClient_RemoveResources_Call) Return(_a0 []*hcloud.Action, _a1 *hcloud.Response, _a2 error) *MockFirewallClient_RemoveResources_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockFirewallClient_RemoveResources_Call) RunAndReturn(run func(context.Context, *hcloud.Firewall, []hcloud.FirewallResource) ([]*hcloud.Action, *hcloud.Response, error)) *MockFirewallClient_RemoveResources_Call { + _c.Call.Return(run) + return _c +} + +// SetRules provides a mock function with given fields: ctx, firewall, opts +func (_m *MockFirewallClient) SetRules(ctx context.Context, firewall *hcloud.Firewall, opts hcloud.FirewallSetRulesOpts) ([]*hcloud.Action, *hcloud.Response, error) { + ret := _m.Called(ctx, firewall, opts) + + if len(ret) == 0 { + panic("no return value specified for SetRules") + } + + var r0 []*hcloud.Action + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Firewall, hcloud.FirewallSetRulesOpts) ([]*hcloud.Action, *hcloud.Response, error)); ok { + return rf(ctx, firewall, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Firewall, hcloud.FirewallSetRulesOpts) []*hcloud.Action); ok { + r0 = rf(ctx, firewall, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*hcloud.Action) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Firewall, hcloud.FirewallSetRulesOpts) *hcloud.Response); ok { + r1 = rf(ctx, firewall, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Firewall, hcloud.FirewallSetRulesOpts) error); ok { + r2 = rf(ctx, firewall, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockFirewallClient_SetRules_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetRules' +type MockFirewallClient_SetRules_Call struct { + *mock.Call +} + +// SetRules is a helper method to define mock.On call +// - ctx context.Context +// - firewall *hcloud.Firewall +// - opts hcloud.FirewallSetRulesOpts +func (_e *MockFirewallClient_Expecter) SetRules(ctx interface{}, firewall interface{}, opts interface{}) *MockFirewallClient_SetRules_Call { + return &MockFirewallClient_SetRules_Call{Call: _e.mock.On("SetRules", ctx, firewall, opts)} +} + +func (_c *MockFirewallClient_SetRules_Call) Run(run func(ctx context.Context, firewall *hcloud.Firewall, opts hcloud.FirewallSetRulesOpts)) *MockFirewallClient_SetRules_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Firewall), args[2].(hcloud.FirewallSetRulesOpts)) + }) + return _c +} + +func (_c *MockFirewallClient_SetRules_Call) Return(_a0 []*hcloud.Action, _a1 *hcloud.Response, _a2 error) *MockFirewallClient_SetRules_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockFirewallClient_SetRules_Call) RunAndReturn(run func(context.Context, *hcloud.Firewall, hcloud.FirewallSetRulesOpts) ([]*hcloud.Action, *hcloud.Response, error)) *MockFirewallClient_SetRules_Call { + _c.Call.Return(run) + return _c +} + +// Update provides a mock function with given fields: ctx, firewall, opts +func (_m *MockFirewallClient) Update(ctx context.Context, firewall *hcloud.Firewall, opts hcloud.FirewallUpdateOpts) (*hcloud.Firewall, *hcloud.Response, error) { + ret := _m.Called(ctx, firewall, opts) + + if len(ret) == 0 { + panic("no return value specified for Update") + } + + var r0 *hcloud.Firewall + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Firewall, hcloud.FirewallUpdateOpts) (*hcloud.Firewall, *hcloud.Response, error)); ok { + return rf(ctx, firewall, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Firewall, hcloud.FirewallUpdateOpts) *hcloud.Firewall); ok { + r0 = rf(ctx, firewall, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Firewall) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Firewall, hcloud.FirewallUpdateOpts) *hcloud.Response); ok { + r1 = rf(ctx, firewall, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Firewall, hcloud.FirewallUpdateOpts) error); ok { + r2 = rf(ctx, firewall, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockFirewallClient_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' +type MockFirewallClient_Update_Call struct { + *mock.Call +} + +// Update is a helper method to define mock.On call +// - ctx context.Context +// - firewall *hcloud.Firewall +// - opts hcloud.FirewallUpdateOpts +func (_e *MockFirewallClient_Expecter) Update(ctx interface{}, firewall interface{}, opts interface{}) *MockFirewallClient_Update_Call { + return &MockFirewallClient_Update_Call{Call: _e.mock.On("Update", ctx, firewall, opts)} +} + +func (_c *MockFirewallClient_Update_Call) Run(run func(ctx context.Context, firewall *hcloud.Firewall, opts hcloud.FirewallUpdateOpts)) *MockFirewallClient_Update_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Firewall), args[2].(hcloud.FirewallUpdateOpts)) + }) + return _c +} + +func (_c *MockFirewallClient_Update_Call) Return(_a0 *hcloud.Firewall, _a1 *hcloud.Response, _a2 error) *MockFirewallClient_Update_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockFirewallClient_Update_Call) RunAndReturn(run func(context.Context, *hcloud.Firewall, hcloud.FirewallUpdateOpts) (*hcloud.Firewall, *hcloud.Response, error)) *MockFirewallClient_Update_Call { + _c.Call.Return(run) + return _c +} + +// NewMockFirewallClient creates a new instance of MockFirewallClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockFirewallClient(t interface { + mock.TestingT + Cleanup(func()) +}) *MockFirewallClient { + mock := &MockFirewallClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/providers/hetznercloud/hcapi/mocks/mock_ImageClient.go b/providers/hetznercloud/hcapi/mocks/mock_ImageClient.go new file mode 100644 index 0000000..4a60274 --- /dev/null +++ b/providers/hetznercloud/hcapi/mocks/mock_ImageClient.go @@ -0,0 +1,762 @@ +// Code generated by mockery. DO NOT EDIT. + +package mocks + +import ( + context "context" + + hcloud "github.com/hetznercloud/hcloud-go/v2/hcloud" + + mock "github.com/stretchr/testify/mock" +) + +// MockImageClient is an autogenerated mock type for the ImageClient type +type MockImageClient struct { + mock.Mock +} + +type MockImageClient_Expecter struct { + mock *mock.Mock +} + +func (_m *MockImageClient) EXPECT() *MockImageClient_Expecter { + return &MockImageClient_Expecter{mock: &_m.Mock} +} + +// All provides a mock function with given fields: ctx +func (_m *MockImageClient) All(ctx context.Context) ([]*hcloud.Image, error) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for All") + } + + var r0 []*hcloud.Image + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) ([]*hcloud.Image, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) []*hcloud.Image); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*hcloud.Image) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockImageClient_All_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'All' +type MockImageClient_All_Call struct { + *mock.Call +} + +// All is a helper method to define mock.On call +// - ctx context.Context +func (_e *MockImageClient_Expecter) All(ctx interface{}) *MockImageClient_All_Call { + return &MockImageClient_All_Call{Call: _e.mock.On("All", ctx)} +} + +func (_c *MockImageClient_All_Call) Run(run func(ctx context.Context)) *MockImageClient_All_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *MockImageClient_All_Call) Return(_a0 []*hcloud.Image, _a1 error) *MockImageClient_All_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockImageClient_All_Call) RunAndReturn(run func(context.Context) ([]*hcloud.Image, error)) *MockImageClient_All_Call { + _c.Call.Return(run) + return _c +} + +// AllWithOpts provides a mock function with given fields: ctx, opts +func (_m *MockImageClient) AllWithOpts(ctx context.Context, opts hcloud.ImageListOpts) ([]*hcloud.Image, error) { + ret := _m.Called(ctx, opts) + + if len(ret) == 0 { + panic("no return value specified for AllWithOpts") + } + + var r0 []*hcloud.Image + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, hcloud.ImageListOpts) ([]*hcloud.Image, error)); ok { + return rf(ctx, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, hcloud.ImageListOpts) []*hcloud.Image); ok { + r0 = rf(ctx, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*hcloud.Image) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, hcloud.ImageListOpts) error); ok { + r1 = rf(ctx, opts) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockImageClient_AllWithOpts_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AllWithOpts' +type MockImageClient_AllWithOpts_Call struct { + *mock.Call +} + +// AllWithOpts is a helper method to define mock.On call +// - ctx context.Context +// - opts hcloud.ImageListOpts +func (_e *MockImageClient_Expecter) AllWithOpts(ctx interface{}, opts interface{}) *MockImageClient_AllWithOpts_Call { + return &MockImageClient_AllWithOpts_Call{Call: _e.mock.On("AllWithOpts", ctx, opts)} +} + +func (_c *MockImageClient_AllWithOpts_Call) Run(run func(ctx context.Context, opts hcloud.ImageListOpts)) *MockImageClient_AllWithOpts_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(hcloud.ImageListOpts)) + }) + return _c +} + +func (_c *MockImageClient_AllWithOpts_Call) Return(_a0 []*hcloud.Image, _a1 error) *MockImageClient_AllWithOpts_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockImageClient_AllWithOpts_Call) RunAndReturn(run func(context.Context, hcloud.ImageListOpts) ([]*hcloud.Image, error)) *MockImageClient_AllWithOpts_Call { + _c.Call.Return(run) + return _c +} + +// ChangeProtection provides a mock function with given fields: ctx, image, opts +func (_m *MockImageClient) ChangeProtection(ctx context.Context, image *hcloud.Image, opts hcloud.ImageChangeProtectionOpts) (*hcloud.Action, *hcloud.Response, error) { + ret := _m.Called(ctx, image, opts) + + if len(ret) == 0 { + panic("no return value specified for ChangeProtection") + } + + var r0 *hcloud.Action + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Image, hcloud.ImageChangeProtectionOpts) (*hcloud.Action, *hcloud.Response, error)); ok { + return rf(ctx, image, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Image, hcloud.ImageChangeProtectionOpts) *hcloud.Action); ok { + r0 = rf(ctx, image, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Action) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Image, hcloud.ImageChangeProtectionOpts) *hcloud.Response); ok { + r1 = rf(ctx, image, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Image, hcloud.ImageChangeProtectionOpts) error); ok { + r2 = rf(ctx, image, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockImageClient_ChangeProtection_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ChangeProtection' +type MockImageClient_ChangeProtection_Call struct { + *mock.Call +} + +// ChangeProtection is a helper method to define mock.On call +// - ctx context.Context +// - image *hcloud.Image +// - opts hcloud.ImageChangeProtectionOpts +func (_e *MockImageClient_Expecter) ChangeProtection(ctx interface{}, image interface{}, opts interface{}) *MockImageClient_ChangeProtection_Call { + return &MockImageClient_ChangeProtection_Call{Call: _e.mock.On("ChangeProtection", ctx, image, opts)} +} + +func (_c *MockImageClient_ChangeProtection_Call) Run(run func(ctx context.Context, image *hcloud.Image, opts hcloud.ImageChangeProtectionOpts)) *MockImageClient_ChangeProtection_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Image), args[2].(hcloud.ImageChangeProtectionOpts)) + }) + return _c +} + +func (_c *MockImageClient_ChangeProtection_Call) Return(_a0 *hcloud.Action, _a1 *hcloud.Response, _a2 error) *MockImageClient_ChangeProtection_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockImageClient_ChangeProtection_Call) RunAndReturn(run func(context.Context, *hcloud.Image, hcloud.ImageChangeProtectionOpts) (*hcloud.Action, *hcloud.Response, error)) *MockImageClient_ChangeProtection_Call { + _c.Call.Return(run) + return _c +} + +// Delete provides a mock function with given fields: ctx, image +func (_m *MockImageClient) Delete(ctx context.Context, image *hcloud.Image) (*hcloud.Response, error) { + ret := _m.Called(ctx, image) + + if len(ret) == 0 { + panic("no return value specified for Delete") + } + + var r0 *hcloud.Response + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Image) (*hcloud.Response, error)); ok { + return rf(ctx, image) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Image) *hcloud.Response); ok { + r0 = rf(ctx, image) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Image) error); ok { + r1 = rf(ctx, image) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockImageClient_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' +type MockImageClient_Delete_Call struct { + *mock.Call +} + +// Delete is a helper method to define mock.On call +// - ctx context.Context +// - image *hcloud.Image +func (_e *MockImageClient_Expecter) Delete(ctx interface{}, image interface{}) *MockImageClient_Delete_Call { + return &MockImageClient_Delete_Call{Call: _e.mock.On("Delete", ctx, image)} +} + +func (_c *MockImageClient_Delete_Call) Run(run func(ctx context.Context, image *hcloud.Image)) *MockImageClient_Delete_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Image)) + }) + return _c +} + +func (_c *MockImageClient_Delete_Call) Return(_a0 *hcloud.Response, _a1 error) *MockImageClient_Delete_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockImageClient_Delete_Call) RunAndReturn(run func(context.Context, *hcloud.Image) (*hcloud.Response, error)) *MockImageClient_Delete_Call { + _c.Call.Return(run) + return _c +} + +// Get provides a mock function with given fields: ctx, idOrName +func (_m *MockImageClient) Get(ctx context.Context, idOrName string) (*hcloud.Image, *hcloud.Response, error) { + ret := _m.Called(ctx, idOrName) + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 *hcloud.Image + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*hcloud.Image, *hcloud.Response, error)); ok { + return rf(ctx, idOrName) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *hcloud.Image); ok { + r0 = rf(ctx, idOrName) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Image) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) *hcloud.Response); ok { + r1 = rf(ctx, idOrName) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, string) error); ok { + r2 = rf(ctx, idOrName) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockImageClient_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type MockImageClient_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +// - ctx context.Context +// - idOrName string +func (_e *MockImageClient_Expecter) Get(ctx interface{}, idOrName interface{}) *MockImageClient_Get_Call { + return &MockImageClient_Get_Call{Call: _e.mock.On("Get", ctx, idOrName)} +} + +func (_c *MockImageClient_Get_Call) Run(run func(ctx context.Context, idOrName string)) *MockImageClient_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockImageClient_Get_Call) Return(_a0 *hcloud.Image, _a1 *hcloud.Response, _a2 error) *MockImageClient_Get_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockImageClient_Get_Call) RunAndReturn(run func(context.Context, string) (*hcloud.Image, *hcloud.Response, error)) *MockImageClient_Get_Call { + _c.Call.Return(run) + return _c +} + +// GetByID provides a mock function with given fields: ctx, id +func (_m *MockImageClient) GetByID(ctx context.Context, id int64) (*hcloud.Image, *hcloud.Response, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for GetByID") + } + + var r0 *hcloud.Image + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, int64) (*hcloud.Image, *hcloud.Response, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, int64) *hcloud.Image); ok { + r0 = rf(ctx, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Image) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, int64) *hcloud.Response); ok { + r1 = rf(ctx, id) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, int64) error); ok { + r2 = rf(ctx, id) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockImageClient_GetByID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByID' +type MockImageClient_GetByID_Call struct { + *mock.Call +} + +// GetByID is a helper method to define mock.On call +// - ctx context.Context +// - id int64 +func (_e *MockImageClient_Expecter) GetByID(ctx interface{}, id interface{}) *MockImageClient_GetByID_Call { + return &MockImageClient_GetByID_Call{Call: _e.mock.On("GetByID", ctx, id)} +} + +func (_c *MockImageClient_GetByID_Call) Run(run func(ctx context.Context, id int64)) *MockImageClient_GetByID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(int64)) + }) + return _c +} + +func (_c *MockImageClient_GetByID_Call) Return(_a0 *hcloud.Image, _a1 *hcloud.Response, _a2 error) *MockImageClient_GetByID_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockImageClient_GetByID_Call) RunAndReturn(run func(context.Context, int64) (*hcloud.Image, *hcloud.Response, error)) *MockImageClient_GetByID_Call { + _c.Call.Return(run) + return _c +} + +// GetByName provides a mock function with given fields: ctx, name +func (_m *MockImageClient) GetByName(ctx context.Context, name string) (*hcloud.Image, *hcloud.Response, error) { + ret := _m.Called(ctx, name) + + if len(ret) == 0 { + panic("no return value specified for GetByName") + } + + var r0 *hcloud.Image + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*hcloud.Image, *hcloud.Response, error)); ok { + return rf(ctx, name) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *hcloud.Image); ok { + r0 = rf(ctx, name) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Image) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) *hcloud.Response); ok { + r1 = rf(ctx, name) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, string) error); ok { + r2 = rf(ctx, name) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockImageClient_GetByName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByName' +type MockImageClient_GetByName_Call struct { + *mock.Call +} + +// GetByName is a helper method to define mock.On call +// - ctx context.Context +// - name string +func (_e *MockImageClient_Expecter) GetByName(ctx interface{}, name interface{}) *MockImageClient_GetByName_Call { + return &MockImageClient_GetByName_Call{Call: _e.mock.On("GetByName", ctx, name)} +} + +func (_c *MockImageClient_GetByName_Call) Run(run func(ctx context.Context, name string)) *MockImageClient_GetByName_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockImageClient_GetByName_Call) Return(_a0 *hcloud.Image, _a1 *hcloud.Response, _a2 error) *MockImageClient_GetByName_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockImageClient_GetByName_Call) RunAndReturn(run func(context.Context, string) (*hcloud.Image, *hcloud.Response, error)) *MockImageClient_GetByName_Call { + _c.Call.Return(run) + return _c +} + +// GetByNameAndArchitecture provides a mock function with given fields: ctx, name, architecture +func (_m *MockImageClient) GetByNameAndArchitecture(ctx context.Context, name string, architecture hcloud.Architecture) (*hcloud.Image, *hcloud.Response, error) { + ret := _m.Called(ctx, name, architecture) + + if len(ret) == 0 { + panic("no return value specified for GetByNameAndArchitecture") + } + + var r0 *hcloud.Image + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string, hcloud.Architecture) (*hcloud.Image, *hcloud.Response, error)); ok { + return rf(ctx, name, architecture) + } + if rf, ok := ret.Get(0).(func(context.Context, string, hcloud.Architecture) *hcloud.Image); ok { + r0 = rf(ctx, name, architecture) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Image) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, hcloud.Architecture) *hcloud.Response); ok { + r1 = rf(ctx, name, architecture) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, string, hcloud.Architecture) error); ok { + r2 = rf(ctx, name, architecture) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockImageClient_GetByNameAndArchitecture_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByNameAndArchitecture' +type MockImageClient_GetByNameAndArchitecture_Call struct { + *mock.Call +} + +// GetByNameAndArchitecture is a helper method to define mock.On call +// - ctx context.Context +// - name string +// - architecture hcloud.Architecture +func (_e *MockImageClient_Expecter) GetByNameAndArchitecture(ctx interface{}, name interface{}, architecture interface{}) *MockImageClient_GetByNameAndArchitecture_Call { + return &MockImageClient_GetByNameAndArchitecture_Call{Call: _e.mock.On("GetByNameAndArchitecture", ctx, name, architecture)} +} + +func (_c *MockImageClient_GetByNameAndArchitecture_Call) Run(run func(ctx context.Context, name string, architecture hcloud.Architecture)) *MockImageClient_GetByNameAndArchitecture_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(hcloud.Architecture)) + }) + return _c +} + +func (_c *MockImageClient_GetByNameAndArchitecture_Call) Return(_a0 *hcloud.Image, _a1 *hcloud.Response, _a2 error) *MockImageClient_GetByNameAndArchitecture_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockImageClient_GetByNameAndArchitecture_Call) RunAndReturn(run func(context.Context, string, hcloud.Architecture) (*hcloud.Image, *hcloud.Response, error)) *MockImageClient_GetByNameAndArchitecture_Call { + _c.Call.Return(run) + return _c +} + +// GetForArchitecture provides a mock function with given fields: ctx, idOrName, architecture +func (_m *MockImageClient) GetForArchitecture(ctx context.Context, idOrName string, architecture hcloud.Architecture) (*hcloud.Image, *hcloud.Response, error) { + ret := _m.Called(ctx, idOrName, architecture) + + if len(ret) == 0 { + panic("no return value specified for GetForArchitecture") + } + + var r0 *hcloud.Image + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string, hcloud.Architecture) (*hcloud.Image, *hcloud.Response, error)); ok { + return rf(ctx, idOrName, architecture) + } + if rf, ok := ret.Get(0).(func(context.Context, string, hcloud.Architecture) *hcloud.Image); ok { + r0 = rf(ctx, idOrName, architecture) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Image) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, hcloud.Architecture) *hcloud.Response); ok { + r1 = rf(ctx, idOrName, architecture) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, string, hcloud.Architecture) error); ok { + r2 = rf(ctx, idOrName, architecture) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockImageClient_GetForArchitecture_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetForArchitecture' +type MockImageClient_GetForArchitecture_Call struct { + *mock.Call +} + +// GetForArchitecture is a helper method to define mock.On call +// - ctx context.Context +// - idOrName string +// - architecture hcloud.Architecture +func (_e *MockImageClient_Expecter) GetForArchitecture(ctx interface{}, idOrName interface{}, architecture interface{}) *MockImageClient_GetForArchitecture_Call { + return &MockImageClient_GetForArchitecture_Call{Call: _e.mock.On("GetForArchitecture", ctx, idOrName, architecture)} +} + +func (_c *MockImageClient_GetForArchitecture_Call) Run(run func(ctx context.Context, idOrName string, architecture hcloud.Architecture)) *MockImageClient_GetForArchitecture_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(hcloud.Architecture)) + }) + return _c +} + +func (_c *MockImageClient_GetForArchitecture_Call) Return(_a0 *hcloud.Image, _a1 *hcloud.Response, _a2 error) *MockImageClient_GetForArchitecture_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockImageClient_GetForArchitecture_Call) RunAndReturn(run func(context.Context, string, hcloud.Architecture) (*hcloud.Image, *hcloud.Response, error)) *MockImageClient_GetForArchitecture_Call { + _c.Call.Return(run) + return _c +} + +// List provides a mock function with given fields: ctx, opts +func (_m *MockImageClient) List(ctx context.Context, opts hcloud.ImageListOpts) ([]*hcloud.Image, *hcloud.Response, error) { + ret := _m.Called(ctx, opts) + + if len(ret) == 0 { + panic("no return value specified for List") + } + + var r0 []*hcloud.Image + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, hcloud.ImageListOpts) ([]*hcloud.Image, *hcloud.Response, error)); ok { + return rf(ctx, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, hcloud.ImageListOpts) []*hcloud.Image); ok { + r0 = rf(ctx, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*hcloud.Image) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, hcloud.ImageListOpts) *hcloud.Response); ok { + r1 = rf(ctx, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, hcloud.ImageListOpts) error); ok { + r2 = rf(ctx, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockImageClient_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' +type MockImageClient_List_Call struct { + *mock.Call +} + +// List is a helper method to define mock.On call +// - ctx context.Context +// - opts hcloud.ImageListOpts +func (_e *MockImageClient_Expecter) List(ctx interface{}, opts interface{}) *MockImageClient_List_Call { + return &MockImageClient_List_Call{Call: _e.mock.On("List", ctx, opts)} +} + +func (_c *MockImageClient_List_Call) Run(run func(ctx context.Context, opts hcloud.ImageListOpts)) *MockImageClient_List_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(hcloud.ImageListOpts)) + }) + return _c +} + +func (_c *MockImageClient_List_Call) Return(_a0 []*hcloud.Image, _a1 *hcloud.Response, _a2 error) *MockImageClient_List_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockImageClient_List_Call) RunAndReturn(run func(context.Context, hcloud.ImageListOpts) ([]*hcloud.Image, *hcloud.Response, error)) *MockImageClient_List_Call { + _c.Call.Return(run) + return _c +} + +// Update provides a mock function with given fields: ctx, image, opts +func (_m *MockImageClient) Update(ctx context.Context, image *hcloud.Image, opts hcloud.ImageUpdateOpts) (*hcloud.Image, *hcloud.Response, error) { + ret := _m.Called(ctx, image, opts) + + if len(ret) == 0 { + panic("no return value specified for Update") + } + + var r0 *hcloud.Image + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Image, hcloud.ImageUpdateOpts) (*hcloud.Image, *hcloud.Response, error)); ok { + return rf(ctx, image, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Image, hcloud.ImageUpdateOpts) *hcloud.Image); ok { + r0 = rf(ctx, image, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Image) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Image, hcloud.ImageUpdateOpts) *hcloud.Response); ok { + r1 = rf(ctx, image, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Image, hcloud.ImageUpdateOpts) error); ok { + r2 = rf(ctx, image, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockImageClient_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' +type MockImageClient_Update_Call struct { + *mock.Call +} + +// Update is a helper method to define mock.On call +// - ctx context.Context +// - image *hcloud.Image +// - opts hcloud.ImageUpdateOpts +func (_e *MockImageClient_Expecter) Update(ctx interface{}, image interface{}, opts interface{}) *MockImageClient_Update_Call { + return &MockImageClient_Update_Call{Call: _e.mock.On("Update", ctx, image, opts)} +} + +func (_c *MockImageClient_Update_Call) Run(run func(ctx context.Context, image *hcloud.Image, opts hcloud.ImageUpdateOpts)) *MockImageClient_Update_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Image), args[2].(hcloud.ImageUpdateOpts)) + }) + return _c +} + +func (_c *MockImageClient_Update_Call) Return(_a0 *hcloud.Image, _a1 *hcloud.Response, _a2 error) *MockImageClient_Update_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockImageClient_Update_Call) RunAndReturn(run func(context.Context, *hcloud.Image, hcloud.ImageUpdateOpts) (*hcloud.Image, *hcloud.Response, error)) *MockImageClient_Update_Call { + _c.Call.Return(run) + return _c +} + +// NewMockImageClient creates a new instance of MockImageClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockImageClient(t interface { + mock.TestingT + Cleanup(func()) +}) *MockImageClient { + mock := &MockImageClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/providers/hetznercloud/hcapi/mocks/mock_NetworkClient.go b/providers/hetznercloud/hcapi/mocks/mock_NetworkClient.go new file mode 100644 index 0000000..67aabb5 --- /dev/null +++ b/providers/hetznercloud/hcapi/mocks/mock_NetworkClient.go @@ -0,0 +1,1037 @@ +// Code generated by mockery. DO NOT EDIT. + +package mocks + +import ( + context "context" + + hcloud "github.com/hetznercloud/hcloud-go/v2/hcloud" + + mock "github.com/stretchr/testify/mock" +) + +// MockNetworkClient is an autogenerated mock type for the NetworkClient type +type MockNetworkClient struct { + mock.Mock +} + +type MockNetworkClient_Expecter struct { + mock *mock.Mock +} + +func (_m *MockNetworkClient) EXPECT() *MockNetworkClient_Expecter { + return &MockNetworkClient_Expecter{mock: &_m.Mock} +} + +// AddRoute provides a mock function with given fields: ctx, network, opts +func (_m *MockNetworkClient) AddRoute(ctx context.Context, network *hcloud.Network, opts hcloud.NetworkAddRouteOpts) (*hcloud.Action, *hcloud.Response, error) { + ret := _m.Called(ctx, network, opts) + + if len(ret) == 0 { + panic("no return value specified for AddRoute") + } + + var r0 *hcloud.Action + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Network, hcloud.NetworkAddRouteOpts) (*hcloud.Action, *hcloud.Response, error)); ok { + return rf(ctx, network, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Network, hcloud.NetworkAddRouteOpts) *hcloud.Action); ok { + r0 = rf(ctx, network, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Action) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Network, hcloud.NetworkAddRouteOpts) *hcloud.Response); ok { + r1 = rf(ctx, network, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Network, hcloud.NetworkAddRouteOpts) error); ok { + r2 = rf(ctx, network, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockNetworkClient_AddRoute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddRoute' +type MockNetworkClient_AddRoute_Call struct { + *mock.Call +} + +// AddRoute is a helper method to define mock.On call +// - ctx context.Context +// - network *hcloud.Network +// - opts hcloud.NetworkAddRouteOpts +func (_e *MockNetworkClient_Expecter) AddRoute(ctx interface{}, network interface{}, opts interface{}) *MockNetworkClient_AddRoute_Call { + return &MockNetworkClient_AddRoute_Call{Call: _e.mock.On("AddRoute", ctx, network, opts)} +} + +func (_c *MockNetworkClient_AddRoute_Call) Run(run func(ctx context.Context, network *hcloud.Network, opts hcloud.NetworkAddRouteOpts)) *MockNetworkClient_AddRoute_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Network), args[2].(hcloud.NetworkAddRouteOpts)) + }) + return _c +} + +func (_c *MockNetworkClient_AddRoute_Call) Return(_a0 *hcloud.Action, _a1 *hcloud.Response, _a2 error) *MockNetworkClient_AddRoute_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockNetworkClient_AddRoute_Call) RunAndReturn(run func(context.Context, *hcloud.Network, hcloud.NetworkAddRouteOpts) (*hcloud.Action, *hcloud.Response, error)) *MockNetworkClient_AddRoute_Call { + _c.Call.Return(run) + return _c +} + +// AddSubnet provides a mock function with given fields: ctx, network, opts +func (_m *MockNetworkClient) AddSubnet(ctx context.Context, network *hcloud.Network, opts hcloud.NetworkAddSubnetOpts) (*hcloud.Action, *hcloud.Response, error) { + ret := _m.Called(ctx, network, opts) + + if len(ret) == 0 { + panic("no return value specified for AddSubnet") + } + + var r0 *hcloud.Action + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Network, hcloud.NetworkAddSubnetOpts) (*hcloud.Action, *hcloud.Response, error)); ok { + return rf(ctx, network, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Network, hcloud.NetworkAddSubnetOpts) *hcloud.Action); ok { + r0 = rf(ctx, network, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Action) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Network, hcloud.NetworkAddSubnetOpts) *hcloud.Response); ok { + r1 = rf(ctx, network, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Network, hcloud.NetworkAddSubnetOpts) error); ok { + r2 = rf(ctx, network, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockNetworkClient_AddSubnet_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddSubnet' +type MockNetworkClient_AddSubnet_Call struct { + *mock.Call +} + +// AddSubnet is a helper method to define mock.On call +// - ctx context.Context +// - network *hcloud.Network +// - opts hcloud.NetworkAddSubnetOpts +func (_e *MockNetworkClient_Expecter) AddSubnet(ctx interface{}, network interface{}, opts interface{}) *MockNetworkClient_AddSubnet_Call { + return &MockNetworkClient_AddSubnet_Call{Call: _e.mock.On("AddSubnet", ctx, network, opts)} +} + +func (_c *MockNetworkClient_AddSubnet_Call) Run(run func(ctx context.Context, network *hcloud.Network, opts hcloud.NetworkAddSubnetOpts)) *MockNetworkClient_AddSubnet_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Network), args[2].(hcloud.NetworkAddSubnetOpts)) + }) + return _c +} + +func (_c *MockNetworkClient_AddSubnet_Call) Return(_a0 *hcloud.Action, _a1 *hcloud.Response, _a2 error) *MockNetworkClient_AddSubnet_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockNetworkClient_AddSubnet_Call) RunAndReturn(run func(context.Context, *hcloud.Network, hcloud.NetworkAddSubnetOpts) (*hcloud.Action, *hcloud.Response, error)) *MockNetworkClient_AddSubnet_Call { + _c.Call.Return(run) + return _c +} + +// All provides a mock function with given fields: ctx +func (_m *MockNetworkClient) All(ctx context.Context) ([]*hcloud.Network, error) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for All") + } + + var r0 []*hcloud.Network + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) ([]*hcloud.Network, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) []*hcloud.Network); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*hcloud.Network) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockNetworkClient_All_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'All' +type MockNetworkClient_All_Call struct { + *mock.Call +} + +// All is a helper method to define mock.On call +// - ctx context.Context +func (_e *MockNetworkClient_Expecter) All(ctx interface{}) *MockNetworkClient_All_Call { + return &MockNetworkClient_All_Call{Call: _e.mock.On("All", ctx)} +} + +func (_c *MockNetworkClient_All_Call) Run(run func(ctx context.Context)) *MockNetworkClient_All_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *MockNetworkClient_All_Call) Return(_a0 []*hcloud.Network, _a1 error) *MockNetworkClient_All_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockNetworkClient_All_Call) RunAndReturn(run func(context.Context) ([]*hcloud.Network, error)) *MockNetworkClient_All_Call { + _c.Call.Return(run) + return _c +} + +// AllWithOpts provides a mock function with given fields: ctx, opts +func (_m *MockNetworkClient) AllWithOpts(ctx context.Context, opts hcloud.NetworkListOpts) ([]*hcloud.Network, error) { + ret := _m.Called(ctx, opts) + + if len(ret) == 0 { + panic("no return value specified for AllWithOpts") + } + + var r0 []*hcloud.Network + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, hcloud.NetworkListOpts) ([]*hcloud.Network, error)); ok { + return rf(ctx, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, hcloud.NetworkListOpts) []*hcloud.Network); ok { + r0 = rf(ctx, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*hcloud.Network) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, hcloud.NetworkListOpts) error); ok { + r1 = rf(ctx, opts) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockNetworkClient_AllWithOpts_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AllWithOpts' +type MockNetworkClient_AllWithOpts_Call struct { + *mock.Call +} + +// AllWithOpts is a helper method to define mock.On call +// - ctx context.Context +// - opts hcloud.NetworkListOpts +func (_e *MockNetworkClient_Expecter) AllWithOpts(ctx interface{}, opts interface{}) *MockNetworkClient_AllWithOpts_Call { + return &MockNetworkClient_AllWithOpts_Call{Call: _e.mock.On("AllWithOpts", ctx, opts)} +} + +func (_c *MockNetworkClient_AllWithOpts_Call) Run(run func(ctx context.Context, opts hcloud.NetworkListOpts)) *MockNetworkClient_AllWithOpts_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(hcloud.NetworkListOpts)) + }) + return _c +} + +func (_c *MockNetworkClient_AllWithOpts_Call) Return(_a0 []*hcloud.Network, _a1 error) *MockNetworkClient_AllWithOpts_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockNetworkClient_AllWithOpts_Call) RunAndReturn(run func(context.Context, hcloud.NetworkListOpts) ([]*hcloud.Network, error)) *MockNetworkClient_AllWithOpts_Call { + _c.Call.Return(run) + return _c +} + +// ChangeIPRange provides a mock function with given fields: ctx, network, opts +func (_m *MockNetworkClient) ChangeIPRange(ctx context.Context, network *hcloud.Network, opts hcloud.NetworkChangeIPRangeOpts) (*hcloud.Action, *hcloud.Response, error) { + ret := _m.Called(ctx, network, opts) + + if len(ret) == 0 { + panic("no return value specified for ChangeIPRange") + } + + var r0 *hcloud.Action + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Network, hcloud.NetworkChangeIPRangeOpts) (*hcloud.Action, *hcloud.Response, error)); ok { + return rf(ctx, network, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Network, hcloud.NetworkChangeIPRangeOpts) *hcloud.Action); ok { + r0 = rf(ctx, network, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Action) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Network, hcloud.NetworkChangeIPRangeOpts) *hcloud.Response); ok { + r1 = rf(ctx, network, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Network, hcloud.NetworkChangeIPRangeOpts) error); ok { + r2 = rf(ctx, network, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockNetworkClient_ChangeIPRange_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ChangeIPRange' +type MockNetworkClient_ChangeIPRange_Call struct { + *mock.Call +} + +// ChangeIPRange is a helper method to define mock.On call +// - ctx context.Context +// - network *hcloud.Network +// - opts hcloud.NetworkChangeIPRangeOpts +func (_e *MockNetworkClient_Expecter) ChangeIPRange(ctx interface{}, network interface{}, opts interface{}) *MockNetworkClient_ChangeIPRange_Call { + return &MockNetworkClient_ChangeIPRange_Call{Call: _e.mock.On("ChangeIPRange", ctx, network, opts)} +} + +func (_c *MockNetworkClient_ChangeIPRange_Call) Run(run func(ctx context.Context, network *hcloud.Network, opts hcloud.NetworkChangeIPRangeOpts)) *MockNetworkClient_ChangeIPRange_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Network), args[2].(hcloud.NetworkChangeIPRangeOpts)) + }) + return _c +} + +func (_c *MockNetworkClient_ChangeIPRange_Call) Return(_a0 *hcloud.Action, _a1 *hcloud.Response, _a2 error) *MockNetworkClient_ChangeIPRange_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockNetworkClient_ChangeIPRange_Call) RunAndReturn(run func(context.Context, *hcloud.Network, hcloud.NetworkChangeIPRangeOpts) (*hcloud.Action, *hcloud.Response, error)) *MockNetworkClient_ChangeIPRange_Call { + _c.Call.Return(run) + return _c +} + +// ChangeProtection provides a mock function with given fields: ctx, network, opts +func (_m *MockNetworkClient) ChangeProtection(ctx context.Context, network *hcloud.Network, opts hcloud.NetworkChangeProtectionOpts) (*hcloud.Action, *hcloud.Response, error) { + ret := _m.Called(ctx, network, opts) + + if len(ret) == 0 { + panic("no return value specified for ChangeProtection") + } + + var r0 *hcloud.Action + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Network, hcloud.NetworkChangeProtectionOpts) (*hcloud.Action, *hcloud.Response, error)); ok { + return rf(ctx, network, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Network, hcloud.NetworkChangeProtectionOpts) *hcloud.Action); ok { + r0 = rf(ctx, network, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Action) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Network, hcloud.NetworkChangeProtectionOpts) *hcloud.Response); ok { + r1 = rf(ctx, network, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Network, hcloud.NetworkChangeProtectionOpts) error); ok { + r2 = rf(ctx, network, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockNetworkClient_ChangeProtection_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ChangeProtection' +type MockNetworkClient_ChangeProtection_Call struct { + *mock.Call +} + +// ChangeProtection is a helper method to define mock.On call +// - ctx context.Context +// - network *hcloud.Network +// - opts hcloud.NetworkChangeProtectionOpts +func (_e *MockNetworkClient_Expecter) ChangeProtection(ctx interface{}, network interface{}, opts interface{}) *MockNetworkClient_ChangeProtection_Call { + return &MockNetworkClient_ChangeProtection_Call{Call: _e.mock.On("ChangeProtection", ctx, network, opts)} +} + +func (_c *MockNetworkClient_ChangeProtection_Call) Run(run func(ctx context.Context, network *hcloud.Network, opts hcloud.NetworkChangeProtectionOpts)) *MockNetworkClient_ChangeProtection_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Network), args[2].(hcloud.NetworkChangeProtectionOpts)) + }) + return _c +} + +func (_c *MockNetworkClient_ChangeProtection_Call) Return(_a0 *hcloud.Action, _a1 *hcloud.Response, _a2 error) *MockNetworkClient_ChangeProtection_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockNetworkClient_ChangeProtection_Call) RunAndReturn(run func(context.Context, *hcloud.Network, hcloud.NetworkChangeProtectionOpts) (*hcloud.Action, *hcloud.Response, error)) *MockNetworkClient_ChangeProtection_Call { + _c.Call.Return(run) + return _c +} + +// Create provides a mock function with given fields: ctx, opts +func (_m *MockNetworkClient) Create(ctx context.Context, opts hcloud.NetworkCreateOpts) (*hcloud.Network, *hcloud.Response, error) { + ret := _m.Called(ctx, opts) + + if len(ret) == 0 { + panic("no return value specified for Create") + } + + var r0 *hcloud.Network + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, hcloud.NetworkCreateOpts) (*hcloud.Network, *hcloud.Response, error)); ok { + return rf(ctx, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, hcloud.NetworkCreateOpts) *hcloud.Network); ok { + r0 = rf(ctx, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Network) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, hcloud.NetworkCreateOpts) *hcloud.Response); ok { + r1 = rf(ctx, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, hcloud.NetworkCreateOpts) error); ok { + r2 = rf(ctx, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockNetworkClient_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type MockNetworkClient_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - opts hcloud.NetworkCreateOpts +func (_e *MockNetworkClient_Expecter) Create(ctx interface{}, opts interface{}) *MockNetworkClient_Create_Call { + return &MockNetworkClient_Create_Call{Call: _e.mock.On("Create", ctx, opts)} +} + +func (_c *MockNetworkClient_Create_Call) Run(run func(ctx context.Context, opts hcloud.NetworkCreateOpts)) *MockNetworkClient_Create_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(hcloud.NetworkCreateOpts)) + }) + return _c +} + +func (_c *MockNetworkClient_Create_Call) Return(_a0 *hcloud.Network, _a1 *hcloud.Response, _a2 error) *MockNetworkClient_Create_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockNetworkClient_Create_Call) RunAndReturn(run func(context.Context, hcloud.NetworkCreateOpts) (*hcloud.Network, *hcloud.Response, error)) *MockNetworkClient_Create_Call { + _c.Call.Return(run) + return _c +} + +// Delete provides a mock function with given fields: ctx, network +func (_m *MockNetworkClient) Delete(ctx context.Context, network *hcloud.Network) (*hcloud.Response, error) { + ret := _m.Called(ctx, network) + + if len(ret) == 0 { + panic("no return value specified for Delete") + } + + var r0 *hcloud.Response + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Network) (*hcloud.Response, error)); ok { + return rf(ctx, network) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Network) *hcloud.Response); ok { + r0 = rf(ctx, network) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Network) error); ok { + r1 = rf(ctx, network) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockNetworkClient_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' +type MockNetworkClient_Delete_Call struct { + *mock.Call +} + +// Delete is a helper method to define mock.On call +// - ctx context.Context +// - network *hcloud.Network +func (_e *MockNetworkClient_Expecter) Delete(ctx interface{}, network interface{}) *MockNetworkClient_Delete_Call { + return &MockNetworkClient_Delete_Call{Call: _e.mock.On("Delete", ctx, network)} +} + +func (_c *MockNetworkClient_Delete_Call) Run(run func(ctx context.Context, network *hcloud.Network)) *MockNetworkClient_Delete_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Network)) + }) + return _c +} + +func (_c *MockNetworkClient_Delete_Call) Return(_a0 *hcloud.Response, _a1 error) *MockNetworkClient_Delete_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockNetworkClient_Delete_Call) RunAndReturn(run func(context.Context, *hcloud.Network) (*hcloud.Response, error)) *MockNetworkClient_Delete_Call { + _c.Call.Return(run) + return _c +} + +// DeleteRoute provides a mock function with given fields: ctx, network, opts +func (_m *MockNetworkClient) DeleteRoute(ctx context.Context, network *hcloud.Network, opts hcloud.NetworkDeleteRouteOpts) (*hcloud.Action, *hcloud.Response, error) { + ret := _m.Called(ctx, network, opts) + + if len(ret) == 0 { + panic("no return value specified for DeleteRoute") + } + + var r0 *hcloud.Action + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Network, hcloud.NetworkDeleteRouteOpts) (*hcloud.Action, *hcloud.Response, error)); ok { + return rf(ctx, network, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Network, hcloud.NetworkDeleteRouteOpts) *hcloud.Action); ok { + r0 = rf(ctx, network, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Action) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Network, hcloud.NetworkDeleteRouteOpts) *hcloud.Response); ok { + r1 = rf(ctx, network, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Network, hcloud.NetworkDeleteRouteOpts) error); ok { + r2 = rf(ctx, network, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockNetworkClient_DeleteRoute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteRoute' +type MockNetworkClient_DeleteRoute_Call struct { + *mock.Call +} + +// DeleteRoute is a helper method to define mock.On call +// - ctx context.Context +// - network *hcloud.Network +// - opts hcloud.NetworkDeleteRouteOpts +func (_e *MockNetworkClient_Expecter) DeleteRoute(ctx interface{}, network interface{}, opts interface{}) *MockNetworkClient_DeleteRoute_Call { + return &MockNetworkClient_DeleteRoute_Call{Call: _e.mock.On("DeleteRoute", ctx, network, opts)} +} + +func (_c *MockNetworkClient_DeleteRoute_Call) Run(run func(ctx context.Context, network *hcloud.Network, opts hcloud.NetworkDeleteRouteOpts)) *MockNetworkClient_DeleteRoute_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Network), args[2].(hcloud.NetworkDeleteRouteOpts)) + }) + return _c +} + +func (_c *MockNetworkClient_DeleteRoute_Call) Return(_a0 *hcloud.Action, _a1 *hcloud.Response, _a2 error) *MockNetworkClient_DeleteRoute_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockNetworkClient_DeleteRoute_Call) RunAndReturn(run func(context.Context, *hcloud.Network, hcloud.NetworkDeleteRouteOpts) (*hcloud.Action, *hcloud.Response, error)) *MockNetworkClient_DeleteRoute_Call { + _c.Call.Return(run) + return _c +} + +// DeleteSubnet provides a mock function with given fields: ctx, network, opts +func (_m *MockNetworkClient) DeleteSubnet(ctx context.Context, network *hcloud.Network, opts hcloud.NetworkDeleteSubnetOpts) (*hcloud.Action, *hcloud.Response, error) { + ret := _m.Called(ctx, network, opts) + + if len(ret) == 0 { + panic("no return value specified for DeleteSubnet") + } + + var r0 *hcloud.Action + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Network, hcloud.NetworkDeleteSubnetOpts) (*hcloud.Action, *hcloud.Response, error)); ok { + return rf(ctx, network, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Network, hcloud.NetworkDeleteSubnetOpts) *hcloud.Action); ok { + r0 = rf(ctx, network, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Action) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Network, hcloud.NetworkDeleteSubnetOpts) *hcloud.Response); ok { + r1 = rf(ctx, network, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Network, hcloud.NetworkDeleteSubnetOpts) error); ok { + r2 = rf(ctx, network, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockNetworkClient_DeleteSubnet_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteSubnet' +type MockNetworkClient_DeleteSubnet_Call struct { + *mock.Call +} + +// DeleteSubnet is a helper method to define mock.On call +// - ctx context.Context +// - network *hcloud.Network +// - opts hcloud.NetworkDeleteSubnetOpts +func (_e *MockNetworkClient_Expecter) DeleteSubnet(ctx interface{}, network interface{}, opts interface{}) *MockNetworkClient_DeleteSubnet_Call { + return &MockNetworkClient_DeleteSubnet_Call{Call: _e.mock.On("DeleteSubnet", ctx, network, opts)} +} + +func (_c *MockNetworkClient_DeleteSubnet_Call) Run(run func(ctx context.Context, network *hcloud.Network, opts hcloud.NetworkDeleteSubnetOpts)) *MockNetworkClient_DeleteSubnet_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Network), args[2].(hcloud.NetworkDeleteSubnetOpts)) + }) + return _c +} + +func (_c *MockNetworkClient_DeleteSubnet_Call) Return(_a0 *hcloud.Action, _a1 *hcloud.Response, _a2 error) *MockNetworkClient_DeleteSubnet_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockNetworkClient_DeleteSubnet_Call) RunAndReturn(run func(context.Context, *hcloud.Network, hcloud.NetworkDeleteSubnetOpts) (*hcloud.Action, *hcloud.Response, error)) *MockNetworkClient_DeleteSubnet_Call { + _c.Call.Return(run) + return _c +} + +// Get provides a mock function with given fields: ctx, idOrName +func (_m *MockNetworkClient) Get(ctx context.Context, idOrName string) (*hcloud.Network, *hcloud.Response, error) { + ret := _m.Called(ctx, idOrName) + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 *hcloud.Network + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*hcloud.Network, *hcloud.Response, error)); ok { + return rf(ctx, idOrName) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *hcloud.Network); ok { + r0 = rf(ctx, idOrName) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Network) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) *hcloud.Response); ok { + r1 = rf(ctx, idOrName) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, string) error); ok { + r2 = rf(ctx, idOrName) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockNetworkClient_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type MockNetworkClient_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +// - ctx context.Context +// - idOrName string +func (_e *MockNetworkClient_Expecter) Get(ctx interface{}, idOrName interface{}) *MockNetworkClient_Get_Call { + return &MockNetworkClient_Get_Call{Call: _e.mock.On("Get", ctx, idOrName)} +} + +func (_c *MockNetworkClient_Get_Call) Run(run func(ctx context.Context, idOrName string)) *MockNetworkClient_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockNetworkClient_Get_Call) Return(_a0 *hcloud.Network, _a1 *hcloud.Response, _a2 error) *MockNetworkClient_Get_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockNetworkClient_Get_Call) RunAndReturn(run func(context.Context, string) (*hcloud.Network, *hcloud.Response, error)) *MockNetworkClient_Get_Call { + _c.Call.Return(run) + return _c +} + +// GetByID provides a mock function with given fields: ctx, id +func (_m *MockNetworkClient) GetByID(ctx context.Context, id int64) (*hcloud.Network, *hcloud.Response, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for GetByID") + } + + var r0 *hcloud.Network + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, int64) (*hcloud.Network, *hcloud.Response, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, int64) *hcloud.Network); ok { + r0 = rf(ctx, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Network) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, int64) *hcloud.Response); ok { + r1 = rf(ctx, id) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, int64) error); ok { + r2 = rf(ctx, id) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockNetworkClient_GetByID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByID' +type MockNetworkClient_GetByID_Call struct { + *mock.Call +} + +// GetByID is a helper method to define mock.On call +// - ctx context.Context +// - id int64 +func (_e *MockNetworkClient_Expecter) GetByID(ctx interface{}, id interface{}) *MockNetworkClient_GetByID_Call { + return &MockNetworkClient_GetByID_Call{Call: _e.mock.On("GetByID", ctx, id)} +} + +func (_c *MockNetworkClient_GetByID_Call) Run(run func(ctx context.Context, id int64)) *MockNetworkClient_GetByID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(int64)) + }) + return _c +} + +func (_c *MockNetworkClient_GetByID_Call) Return(_a0 *hcloud.Network, _a1 *hcloud.Response, _a2 error) *MockNetworkClient_GetByID_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockNetworkClient_GetByID_Call) RunAndReturn(run func(context.Context, int64) (*hcloud.Network, *hcloud.Response, error)) *MockNetworkClient_GetByID_Call { + _c.Call.Return(run) + return _c +} + +// GetByName provides a mock function with given fields: ctx, name +func (_m *MockNetworkClient) GetByName(ctx context.Context, name string) (*hcloud.Network, *hcloud.Response, error) { + ret := _m.Called(ctx, name) + + if len(ret) == 0 { + panic("no return value specified for GetByName") + } + + var r0 *hcloud.Network + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*hcloud.Network, *hcloud.Response, error)); ok { + return rf(ctx, name) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *hcloud.Network); ok { + r0 = rf(ctx, name) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Network) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) *hcloud.Response); ok { + r1 = rf(ctx, name) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, string) error); ok { + r2 = rf(ctx, name) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockNetworkClient_GetByName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByName' +type MockNetworkClient_GetByName_Call struct { + *mock.Call +} + +// GetByName is a helper method to define mock.On call +// - ctx context.Context +// - name string +func (_e *MockNetworkClient_Expecter) GetByName(ctx interface{}, name interface{}) *MockNetworkClient_GetByName_Call { + return &MockNetworkClient_GetByName_Call{Call: _e.mock.On("GetByName", ctx, name)} +} + +func (_c *MockNetworkClient_GetByName_Call) Run(run func(ctx context.Context, name string)) *MockNetworkClient_GetByName_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockNetworkClient_GetByName_Call) Return(_a0 *hcloud.Network, _a1 *hcloud.Response, _a2 error) *MockNetworkClient_GetByName_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockNetworkClient_GetByName_Call) RunAndReturn(run func(context.Context, string) (*hcloud.Network, *hcloud.Response, error)) *MockNetworkClient_GetByName_Call { + _c.Call.Return(run) + return _c +} + +// List provides a mock function with given fields: ctx, opts +func (_m *MockNetworkClient) List(ctx context.Context, opts hcloud.NetworkListOpts) ([]*hcloud.Network, *hcloud.Response, error) { + ret := _m.Called(ctx, opts) + + if len(ret) == 0 { + panic("no return value specified for List") + } + + var r0 []*hcloud.Network + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, hcloud.NetworkListOpts) ([]*hcloud.Network, *hcloud.Response, error)); ok { + return rf(ctx, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, hcloud.NetworkListOpts) []*hcloud.Network); ok { + r0 = rf(ctx, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*hcloud.Network) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, hcloud.NetworkListOpts) *hcloud.Response); ok { + r1 = rf(ctx, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, hcloud.NetworkListOpts) error); ok { + r2 = rf(ctx, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockNetworkClient_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' +type MockNetworkClient_List_Call struct { + *mock.Call +} + +// List is a helper method to define mock.On call +// - ctx context.Context +// - opts hcloud.NetworkListOpts +func (_e *MockNetworkClient_Expecter) List(ctx interface{}, opts interface{}) *MockNetworkClient_List_Call { + return &MockNetworkClient_List_Call{Call: _e.mock.On("List", ctx, opts)} +} + +func (_c *MockNetworkClient_List_Call) Run(run func(ctx context.Context, opts hcloud.NetworkListOpts)) *MockNetworkClient_List_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(hcloud.NetworkListOpts)) + }) + return _c +} + +func (_c *MockNetworkClient_List_Call) Return(_a0 []*hcloud.Network, _a1 *hcloud.Response, _a2 error) *MockNetworkClient_List_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockNetworkClient_List_Call) RunAndReturn(run func(context.Context, hcloud.NetworkListOpts) ([]*hcloud.Network, *hcloud.Response, error)) *MockNetworkClient_List_Call { + _c.Call.Return(run) + return _c +} + +// Update provides a mock function with given fields: ctx, network, opts +func (_m *MockNetworkClient) Update(ctx context.Context, network *hcloud.Network, opts hcloud.NetworkUpdateOpts) (*hcloud.Network, *hcloud.Response, error) { + ret := _m.Called(ctx, network, opts) + + if len(ret) == 0 { + panic("no return value specified for Update") + } + + var r0 *hcloud.Network + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Network, hcloud.NetworkUpdateOpts) (*hcloud.Network, *hcloud.Response, error)); ok { + return rf(ctx, network, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Network, hcloud.NetworkUpdateOpts) *hcloud.Network); ok { + r0 = rf(ctx, network, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Network) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Network, hcloud.NetworkUpdateOpts) *hcloud.Response); ok { + r1 = rf(ctx, network, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Network, hcloud.NetworkUpdateOpts) error); ok { + r2 = rf(ctx, network, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockNetworkClient_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' +type MockNetworkClient_Update_Call struct { + *mock.Call +} + +// Update is a helper method to define mock.On call +// - ctx context.Context +// - network *hcloud.Network +// - opts hcloud.NetworkUpdateOpts +func (_e *MockNetworkClient_Expecter) Update(ctx interface{}, network interface{}, opts interface{}) *MockNetworkClient_Update_Call { + return &MockNetworkClient_Update_Call{Call: _e.mock.On("Update", ctx, network, opts)} +} + +func (_c *MockNetworkClient_Update_Call) Run(run func(ctx context.Context, network *hcloud.Network, opts hcloud.NetworkUpdateOpts)) *MockNetworkClient_Update_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Network), args[2].(hcloud.NetworkUpdateOpts)) + }) + return _c +} + +func (_c *MockNetworkClient_Update_Call) Return(_a0 *hcloud.Network, _a1 *hcloud.Response, _a2 error) *MockNetworkClient_Update_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockNetworkClient_Update_Call) RunAndReturn(run func(context.Context, *hcloud.Network, hcloud.NetworkUpdateOpts) (*hcloud.Network, *hcloud.Response, error)) *MockNetworkClient_Update_Call { + _c.Call.Return(run) + return _c +} + +// NewMockNetworkClient creates a new instance of MockNetworkClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockNetworkClient(t interface { + mock.TestingT + Cleanup(func()) +}) *MockNetworkClient { + mock := &MockNetworkClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/providers/hetznercloud/hcapi/mocks/mock_SSHKeyClient.go b/providers/hetznercloud/hcapi/mocks/mock_SSHKeyClient.go new file mode 100644 index 0000000..99fa641 --- /dev/null +++ b/providers/hetznercloud/hcapi/mocks/mock_SSHKeyClient.go @@ -0,0 +1,691 @@ +// Code generated by mockery. DO NOT EDIT. + +package mocks + +import ( + context "context" + + hcloud "github.com/hetznercloud/hcloud-go/v2/hcloud" + + mock "github.com/stretchr/testify/mock" +) + +// MockSSHKeyClient is an autogenerated mock type for the SSHKeyClient type +type MockSSHKeyClient struct { + mock.Mock +} + +type MockSSHKeyClient_Expecter struct { + mock *mock.Mock +} + +func (_m *MockSSHKeyClient) EXPECT() *MockSSHKeyClient_Expecter { + return &MockSSHKeyClient_Expecter{mock: &_m.Mock} +} + +// All provides a mock function with given fields: ctx +func (_m *MockSSHKeyClient) All(ctx context.Context) ([]*hcloud.SSHKey, error) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for All") + } + + var r0 []*hcloud.SSHKey + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) ([]*hcloud.SSHKey, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) []*hcloud.SSHKey); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*hcloud.SSHKey) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockSSHKeyClient_All_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'All' +type MockSSHKeyClient_All_Call struct { + *mock.Call +} + +// All is a helper method to define mock.On call +// - ctx context.Context +func (_e *MockSSHKeyClient_Expecter) All(ctx interface{}) *MockSSHKeyClient_All_Call { + return &MockSSHKeyClient_All_Call{Call: _e.mock.On("All", ctx)} +} + +func (_c *MockSSHKeyClient_All_Call) Run(run func(ctx context.Context)) *MockSSHKeyClient_All_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *MockSSHKeyClient_All_Call) Return(_a0 []*hcloud.SSHKey, _a1 error) *MockSSHKeyClient_All_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockSSHKeyClient_All_Call) RunAndReturn(run func(context.Context) ([]*hcloud.SSHKey, error)) *MockSSHKeyClient_All_Call { + _c.Call.Return(run) + return _c +} + +// AllWithOpts provides a mock function with given fields: ctx, opts +func (_m *MockSSHKeyClient) AllWithOpts(ctx context.Context, opts hcloud.SSHKeyListOpts) ([]*hcloud.SSHKey, error) { + ret := _m.Called(ctx, opts) + + if len(ret) == 0 { + panic("no return value specified for AllWithOpts") + } + + var r0 []*hcloud.SSHKey + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, hcloud.SSHKeyListOpts) ([]*hcloud.SSHKey, error)); ok { + return rf(ctx, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, hcloud.SSHKeyListOpts) []*hcloud.SSHKey); ok { + r0 = rf(ctx, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*hcloud.SSHKey) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, hcloud.SSHKeyListOpts) error); ok { + r1 = rf(ctx, opts) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockSSHKeyClient_AllWithOpts_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AllWithOpts' +type MockSSHKeyClient_AllWithOpts_Call struct { + *mock.Call +} + +// AllWithOpts is a helper method to define mock.On call +// - ctx context.Context +// - opts hcloud.SSHKeyListOpts +func (_e *MockSSHKeyClient_Expecter) AllWithOpts(ctx interface{}, opts interface{}) *MockSSHKeyClient_AllWithOpts_Call { + return &MockSSHKeyClient_AllWithOpts_Call{Call: _e.mock.On("AllWithOpts", ctx, opts)} +} + +func (_c *MockSSHKeyClient_AllWithOpts_Call) Run(run func(ctx context.Context, opts hcloud.SSHKeyListOpts)) *MockSSHKeyClient_AllWithOpts_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(hcloud.SSHKeyListOpts)) + }) + return _c +} + +func (_c *MockSSHKeyClient_AllWithOpts_Call) Return(_a0 []*hcloud.SSHKey, _a1 error) *MockSSHKeyClient_AllWithOpts_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockSSHKeyClient_AllWithOpts_Call) RunAndReturn(run func(context.Context, hcloud.SSHKeyListOpts) ([]*hcloud.SSHKey, error)) *MockSSHKeyClient_AllWithOpts_Call { + _c.Call.Return(run) + return _c +} + +// Create provides a mock function with given fields: ctx, opts +func (_m *MockSSHKeyClient) Create(ctx context.Context, opts hcloud.SSHKeyCreateOpts) (*hcloud.SSHKey, *hcloud.Response, error) { + ret := _m.Called(ctx, opts) + + if len(ret) == 0 { + panic("no return value specified for Create") + } + + var r0 *hcloud.SSHKey + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, hcloud.SSHKeyCreateOpts) (*hcloud.SSHKey, *hcloud.Response, error)); ok { + return rf(ctx, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, hcloud.SSHKeyCreateOpts) *hcloud.SSHKey); ok { + r0 = rf(ctx, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.SSHKey) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, hcloud.SSHKeyCreateOpts) *hcloud.Response); ok { + r1 = rf(ctx, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, hcloud.SSHKeyCreateOpts) error); ok { + r2 = rf(ctx, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockSSHKeyClient_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type MockSSHKeyClient_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - opts hcloud.SSHKeyCreateOpts +func (_e *MockSSHKeyClient_Expecter) Create(ctx interface{}, opts interface{}) *MockSSHKeyClient_Create_Call { + return &MockSSHKeyClient_Create_Call{Call: _e.mock.On("Create", ctx, opts)} +} + +func (_c *MockSSHKeyClient_Create_Call) Run(run func(ctx context.Context, opts hcloud.SSHKeyCreateOpts)) *MockSSHKeyClient_Create_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(hcloud.SSHKeyCreateOpts)) + }) + return _c +} + +func (_c *MockSSHKeyClient_Create_Call) Return(_a0 *hcloud.SSHKey, _a1 *hcloud.Response, _a2 error) *MockSSHKeyClient_Create_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockSSHKeyClient_Create_Call) RunAndReturn(run func(context.Context, hcloud.SSHKeyCreateOpts) (*hcloud.SSHKey, *hcloud.Response, error)) *MockSSHKeyClient_Create_Call { + _c.Call.Return(run) + return _c +} + +// Delete provides a mock function with given fields: ctx, sshKey +func (_m *MockSSHKeyClient) Delete(ctx context.Context, sshKey *hcloud.SSHKey) (*hcloud.Response, error) { + ret := _m.Called(ctx, sshKey) + + if len(ret) == 0 { + panic("no return value specified for Delete") + } + + var r0 *hcloud.Response + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.SSHKey) (*hcloud.Response, error)); ok { + return rf(ctx, sshKey) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.SSHKey) *hcloud.Response); ok { + r0 = rf(ctx, sshKey) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.SSHKey) error); ok { + r1 = rf(ctx, sshKey) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockSSHKeyClient_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' +type MockSSHKeyClient_Delete_Call struct { + *mock.Call +} + +// Delete is a helper method to define mock.On call +// - ctx context.Context +// - sshKey *hcloud.SSHKey +func (_e *MockSSHKeyClient_Expecter) Delete(ctx interface{}, sshKey interface{}) *MockSSHKeyClient_Delete_Call { + return &MockSSHKeyClient_Delete_Call{Call: _e.mock.On("Delete", ctx, sshKey)} +} + +func (_c *MockSSHKeyClient_Delete_Call) Run(run func(ctx context.Context, sshKey *hcloud.SSHKey)) *MockSSHKeyClient_Delete_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.SSHKey)) + }) + return _c +} + +func (_c *MockSSHKeyClient_Delete_Call) Return(_a0 *hcloud.Response, _a1 error) *MockSSHKeyClient_Delete_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockSSHKeyClient_Delete_Call) RunAndReturn(run func(context.Context, *hcloud.SSHKey) (*hcloud.Response, error)) *MockSSHKeyClient_Delete_Call { + _c.Call.Return(run) + return _c +} + +// Get provides a mock function with given fields: ctx, idOrName +func (_m *MockSSHKeyClient) Get(ctx context.Context, idOrName string) (*hcloud.SSHKey, *hcloud.Response, error) { + ret := _m.Called(ctx, idOrName) + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 *hcloud.SSHKey + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*hcloud.SSHKey, *hcloud.Response, error)); ok { + return rf(ctx, idOrName) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *hcloud.SSHKey); ok { + r0 = rf(ctx, idOrName) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.SSHKey) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) *hcloud.Response); ok { + r1 = rf(ctx, idOrName) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, string) error); ok { + r2 = rf(ctx, idOrName) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockSSHKeyClient_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type MockSSHKeyClient_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +// - ctx context.Context +// - idOrName string +func (_e *MockSSHKeyClient_Expecter) Get(ctx interface{}, idOrName interface{}) *MockSSHKeyClient_Get_Call { + return &MockSSHKeyClient_Get_Call{Call: _e.mock.On("Get", ctx, idOrName)} +} + +func (_c *MockSSHKeyClient_Get_Call) Run(run func(ctx context.Context, idOrName string)) *MockSSHKeyClient_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockSSHKeyClient_Get_Call) Return(_a0 *hcloud.SSHKey, _a1 *hcloud.Response, _a2 error) *MockSSHKeyClient_Get_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockSSHKeyClient_Get_Call) RunAndReturn(run func(context.Context, string) (*hcloud.SSHKey, *hcloud.Response, error)) *MockSSHKeyClient_Get_Call { + _c.Call.Return(run) + return _c +} + +// GetByFingerprint provides a mock function with given fields: ctx, fingerprint +func (_m *MockSSHKeyClient) GetByFingerprint(ctx context.Context, fingerprint string) (*hcloud.SSHKey, *hcloud.Response, error) { + ret := _m.Called(ctx, fingerprint) + + if len(ret) == 0 { + panic("no return value specified for GetByFingerprint") + } + + var r0 *hcloud.SSHKey + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*hcloud.SSHKey, *hcloud.Response, error)); ok { + return rf(ctx, fingerprint) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *hcloud.SSHKey); ok { + r0 = rf(ctx, fingerprint) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.SSHKey) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) *hcloud.Response); ok { + r1 = rf(ctx, fingerprint) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, string) error); ok { + r2 = rf(ctx, fingerprint) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockSSHKeyClient_GetByFingerprint_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByFingerprint' +type MockSSHKeyClient_GetByFingerprint_Call struct { + *mock.Call +} + +// GetByFingerprint is a helper method to define mock.On call +// - ctx context.Context +// - fingerprint string +func (_e *MockSSHKeyClient_Expecter) GetByFingerprint(ctx interface{}, fingerprint interface{}) *MockSSHKeyClient_GetByFingerprint_Call { + return &MockSSHKeyClient_GetByFingerprint_Call{Call: _e.mock.On("GetByFingerprint", ctx, fingerprint)} +} + +func (_c *MockSSHKeyClient_GetByFingerprint_Call) Run(run func(ctx context.Context, fingerprint string)) *MockSSHKeyClient_GetByFingerprint_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockSSHKeyClient_GetByFingerprint_Call) Return(_a0 *hcloud.SSHKey, _a1 *hcloud.Response, _a2 error) *MockSSHKeyClient_GetByFingerprint_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockSSHKeyClient_GetByFingerprint_Call) RunAndReturn(run func(context.Context, string) (*hcloud.SSHKey, *hcloud.Response, error)) *MockSSHKeyClient_GetByFingerprint_Call { + _c.Call.Return(run) + return _c +} + +// GetByID provides a mock function with given fields: ctx, id +func (_m *MockSSHKeyClient) GetByID(ctx context.Context, id int64) (*hcloud.SSHKey, *hcloud.Response, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for GetByID") + } + + var r0 *hcloud.SSHKey + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, int64) (*hcloud.SSHKey, *hcloud.Response, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, int64) *hcloud.SSHKey); ok { + r0 = rf(ctx, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.SSHKey) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, int64) *hcloud.Response); ok { + r1 = rf(ctx, id) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, int64) error); ok { + r2 = rf(ctx, id) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockSSHKeyClient_GetByID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByID' +type MockSSHKeyClient_GetByID_Call struct { + *mock.Call +} + +// GetByID is a helper method to define mock.On call +// - ctx context.Context +// - id int64 +func (_e *MockSSHKeyClient_Expecter) GetByID(ctx interface{}, id interface{}) *MockSSHKeyClient_GetByID_Call { + return &MockSSHKeyClient_GetByID_Call{Call: _e.mock.On("GetByID", ctx, id)} +} + +func (_c *MockSSHKeyClient_GetByID_Call) Run(run func(ctx context.Context, id int64)) *MockSSHKeyClient_GetByID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(int64)) + }) + return _c +} + +func (_c *MockSSHKeyClient_GetByID_Call) Return(_a0 *hcloud.SSHKey, _a1 *hcloud.Response, _a2 error) *MockSSHKeyClient_GetByID_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockSSHKeyClient_GetByID_Call) RunAndReturn(run func(context.Context, int64) (*hcloud.SSHKey, *hcloud.Response, error)) *MockSSHKeyClient_GetByID_Call { + _c.Call.Return(run) + return _c +} + +// GetByName provides a mock function with given fields: ctx, name +func (_m *MockSSHKeyClient) GetByName(ctx context.Context, name string) (*hcloud.SSHKey, *hcloud.Response, error) { + ret := _m.Called(ctx, name) + + if len(ret) == 0 { + panic("no return value specified for GetByName") + } + + var r0 *hcloud.SSHKey + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*hcloud.SSHKey, *hcloud.Response, error)); ok { + return rf(ctx, name) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *hcloud.SSHKey); ok { + r0 = rf(ctx, name) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.SSHKey) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) *hcloud.Response); ok { + r1 = rf(ctx, name) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, string) error); ok { + r2 = rf(ctx, name) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockSSHKeyClient_GetByName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByName' +type MockSSHKeyClient_GetByName_Call struct { + *mock.Call +} + +// GetByName is a helper method to define mock.On call +// - ctx context.Context +// - name string +func (_e *MockSSHKeyClient_Expecter) GetByName(ctx interface{}, name interface{}) *MockSSHKeyClient_GetByName_Call { + return &MockSSHKeyClient_GetByName_Call{Call: _e.mock.On("GetByName", ctx, name)} +} + +func (_c *MockSSHKeyClient_GetByName_Call) Run(run func(ctx context.Context, name string)) *MockSSHKeyClient_GetByName_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockSSHKeyClient_GetByName_Call) Return(_a0 *hcloud.SSHKey, _a1 *hcloud.Response, _a2 error) *MockSSHKeyClient_GetByName_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockSSHKeyClient_GetByName_Call) RunAndReturn(run func(context.Context, string) (*hcloud.SSHKey, *hcloud.Response, error)) *MockSSHKeyClient_GetByName_Call { + _c.Call.Return(run) + return _c +} + +// List provides a mock function with given fields: ctx, opts +func (_m *MockSSHKeyClient) List(ctx context.Context, opts hcloud.SSHKeyListOpts) ([]*hcloud.SSHKey, *hcloud.Response, error) { + ret := _m.Called(ctx, opts) + + if len(ret) == 0 { + panic("no return value specified for List") + } + + var r0 []*hcloud.SSHKey + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, hcloud.SSHKeyListOpts) ([]*hcloud.SSHKey, *hcloud.Response, error)); ok { + return rf(ctx, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, hcloud.SSHKeyListOpts) []*hcloud.SSHKey); ok { + r0 = rf(ctx, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*hcloud.SSHKey) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, hcloud.SSHKeyListOpts) *hcloud.Response); ok { + r1 = rf(ctx, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, hcloud.SSHKeyListOpts) error); ok { + r2 = rf(ctx, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockSSHKeyClient_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' +type MockSSHKeyClient_List_Call struct { + *mock.Call +} + +// List is a helper method to define mock.On call +// - ctx context.Context +// - opts hcloud.SSHKeyListOpts +func (_e *MockSSHKeyClient_Expecter) List(ctx interface{}, opts interface{}) *MockSSHKeyClient_List_Call { + return &MockSSHKeyClient_List_Call{Call: _e.mock.On("List", ctx, opts)} +} + +func (_c *MockSSHKeyClient_List_Call) Run(run func(ctx context.Context, opts hcloud.SSHKeyListOpts)) *MockSSHKeyClient_List_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(hcloud.SSHKeyListOpts)) + }) + return _c +} + +func (_c *MockSSHKeyClient_List_Call) Return(_a0 []*hcloud.SSHKey, _a1 *hcloud.Response, _a2 error) *MockSSHKeyClient_List_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockSSHKeyClient_List_Call) RunAndReturn(run func(context.Context, hcloud.SSHKeyListOpts) ([]*hcloud.SSHKey, *hcloud.Response, error)) *MockSSHKeyClient_List_Call { + _c.Call.Return(run) + return _c +} + +// Update provides a mock function with given fields: ctx, sshKey, opts +func (_m *MockSSHKeyClient) Update(ctx context.Context, sshKey *hcloud.SSHKey, opts hcloud.SSHKeyUpdateOpts) (*hcloud.SSHKey, *hcloud.Response, error) { + ret := _m.Called(ctx, sshKey, opts) + + if len(ret) == 0 { + panic("no return value specified for Update") + } + + var r0 *hcloud.SSHKey + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.SSHKey, hcloud.SSHKeyUpdateOpts) (*hcloud.SSHKey, *hcloud.Response, error)); ok { + return rf(ctx, sshKey, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.SSHKey, hcloud.SSHKeyUpdateOpts) *hcloud.SSHKey); ok { + r0 = rf(ctx, sshKey, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.SSHKey) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.SSHKey, hcloud.SSHKeyUpdateOpts) *hcloud.Response); ok { + r1 = rf(ctx, sshKey, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.SSHKey, hcloud.SSHKeyUpdateOpts) error); ok { + r2 = rf(ctx, sshKey, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockSSHKeyClient_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' +type MockSSHKeyClient_Update_Call struct { + *mock.Call +} + +// Update is a helper method to define mock.On call +// - ctx context.Context +// - sshKey *hcloud.SSHKey +// - opts hcloud.SSHKeyUpdateOpts +func (_e *MockSSHKeyClient_Expecter) Update(ctx interface{}, sshKey interface{}, opts interface{}) *MockSSHKeyClient_Update_Call { + return &MockSSHKeyClient_Update_Call{Call: _e.mock.On("Update", ctx, sshKey, opts)} +} + +func (_c *MockSSHKeyClient_Update_Call) Run(run func(ctx context.Context, sshKey *hcloud.SSHKey, opts hcloud.SSHKeyUpdateOpts)) *MockSSHKeyClient_Update_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.SSHKey), args[2].(hcloud.SSHKeyUpdateOpts)) + }) + return _c +} + +func (_c *MockSSHKeyClient_Update_Call) Return(_a0 *hcloud.SSHKey, _a1 *hcloud.Response, _a2 error) *MockSSHKeyClient_Update_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockSSHKeyClient_Update_Call) RunAndReturn(run func(context.Context, *hcloud.SSHKey, hcloud.SSHKeyUpdateOpts) (*hcloud.SSHKey, *hcloud.Response, error)) *MockSSHKeyClient_Update_Call { + _c.Call.Return(run) + return _c +} + +// NewMockSSHKeyClient creates a new instance of MockSSHKeyClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockSSHKeyClient(t interface { + mock.TestingT + Cleanup(func()) +}) *MockSSHKeyClient { + mock := &MockSSHKeyClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/providers/hetznercloud/hcapi/mocks/mock_ServerClient.go b/providers/hetznercloud/hcapi/mocks/mock_ServerClient.go new file mode 100644 index 0000000..363b89e --- /dev/null +++ b/providers/hetznercloud/hcapi/mocks/mock_ServerClient.go @@ -0,0 +1,2394 @@ +// Code generated by mockery. DO NOT EDIT. + +package mocks + +import ( + context "context" + + hcloud "github.com/hetznercloud/hcloud-go/v2/hcloud" + + mock "github.com/stretchr/testify/mock" +) + +// MockServerClient is an autogenerated mock type for the ServerClient type +type MockServerClient struct { + mock.Mock +} + +type MockServerClient_Expecter struct { + mock *mock.Mock +} + +func (_m *MockServerClient) EXPECT() *MockServerClient_Expecter { + return &MockServerClient_Expecter{mock: &_m.Mock} +} + +// AddToPlacementGroup provides a mock function with given fields: ctx, server, placementGroup +func (_m *MockServerClient) AddToPlacementGroup(ctx context.Context, server *hcloud.Server, placementGroup *hcloud.PlacementGroup) (*hcloud.Action, *hcloud.Response, error) { + ret := _m.Called(ctx, server, placementGroup) + + if len(ret) == 0 { + panic("no return value specified for AddToPlacementGroup") + } + + var r0 *hcloud.Action + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server, *hcloud.PlacementGroup) (*hcloud.Action, *hcloud.Response, error)); ok { + return rf(ctx, server, placementGroup) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server, *hcloud.PlacementGroup) *hcloud.Action); ok { + r0 = rf(ctx, server, placementGroup) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Action) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Server, *hcloud.PlacementGroup) *hcloud.Response); ok { + r1 = rf(ctx, server, placementGroup) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Server, *hcloud.PlacementGroup) error); ok { + r2 = rf(ctx, server, placementGroup) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_AddToPlacementGroup_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddToPlacementGroup' +type MockServerClient_AddToPlacementGroup_Call struct { + *mock.Call +} + +// AddToPlacementGroup is a helper method to define mock.On call +// - ctx context.Context +// - server *hcloud.Server +// - placementGroup *hcloud.PlacementGroup +func (_e *MockServerClient_Expecter) AddToPlacementGroup(ctx interface{}, server interface{}, placementGroup interface{}) *MockServerClient_AddToPlacementGroup_Call { + return &MockServerClient_AddToPlacementGroup_Call{Call: _e.mock.On("AddToPlacementGroup", ctx, server, placementGroup)} +} + +func (_c *MockServerClient_AddToPlacementGroup_Call) Run(run func(ctx context.Context, server *hcloud.Server, placementGroup *hcloud.PlacementGroup)) *MockServerClient_AddToPlacementGroup_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Server), args[2].(*hcloud.PlacementGroup)) + }) + return _c +} + +func (_c *MockServerClient_AddToPlacementGroup_Call) Return(_a0 *hcloud.Action, _a1 *hcloud.Response, _a2 error) *MockServerClient_AddToPlacementGroup_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_AddToPlacementGroup_Call) RunAndReturn(run func(context.Context, *hcloud.Server, *hcloud.PlacementGroup) (*hcloud.Action, *hcloud.Response, error)) *MockServerClient_AddToPlacementGroup_Call { + _c.Call.Return(run) + return _c +} + +// All provides a mock function with given fields: ctx +func (_m *MockServerClient) All(ctx context.Context) ([]*hcloud.Server, error) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for All") + } + + var r0 []*hcloud.Server + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) ([]*hcloud.Server, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) []*hcloud.Server); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*hcloud.Server) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockServerClient_All_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'All' +type MockServerClient_All_Call struct { + *mock.Call +} + +// All is a helper method to define mock.On call +// - ctx context.Context +func (_e *MockServerClient_Expecter) All(ctx interface{}) *MockServerClient_All_Call { + return &MockServerClient_All_Call{Call: _e.mock.On("All", ctx)} +} + +func (_c *MockServerClient_All_Call) Run(run func(ctx context.Context)) *MockServerClient_All_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *MockServerClient_All_Call) Return(_a0 []*hcloud.Server, _a1 error) *MockServerClient_All_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockServerClient_All_Call) RunAndReturn(run func(context.Context) ([]*hcloud.Server, error)) *MockServerClient_All_Call { + _c.Call.Return(run) + return _c +} + +// AllWithOpts provides a mock function with given fields: ctx, opts +func (_m *MockServerClient) AllWithOpts(ctx context.Context, opts hcloud.ServerListOpts) ([]*hcloud.Server, error) { + ret := _m.Called(ctx, opts) + + if len(ret) == 0 { + panic("no return value specified for AllWithOpts") + } + + var r0 []*hcloud.Server + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, hcloud.ServerListOpts) ([]*hcloud.Server, error)); ok { + return rf(ctx, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, hcloud.ServerListOpts) []*hcloud.Server); ok { + r0 = rf(ctx, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*hcloud.Server) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, hcloud.ServerListOpts) error); ok { + r1 = rf(ctx, opts) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockServerClient_AllWithOpts_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AllWithOpts' +type MockServerClient_AllWithOpts_Call struct { + *mock.Call +} + +// AllWithOpts is a helper method to define mock.On call +// - ctx context.Context +// - opts hcloud.ServerListOpts +func (_e *MockServerClient_Expecter) AllWithOpts(ctx interface{}, opts interface{}) *MockServerClient_AllWithOpts_Call { + return &MockServerClient_AllWithOpts_Call{Call: _e.mock.On("AllWithOpts", ctx, opts)} +} + +func (_c *MockServerClient_AllWithOpts_Call) Run(run func(ctx context.Context, opts hcloud.ServerListOpts)) *MockServerClient_AllWithOpts_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(hcloud.ServerListOpts)) + }) + return _c +} + +func (_c *MockServerClient_AllWithOpts_Call) Return(_a0 []*hcloud.Server, _a1 error) *MockServerClient_AllWithOpts_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockServerClient_AllWithOpts_Call) RunAndReturn(run func(context.Context, hcloud.ServerListOpts) ([]*hcloud.Server, error)) *MockServerClient_AllWithOpts_Call { + _c.Call.Return(run) + return _c +} + +// AttachISO provides a mock function with given fields: ctx, server, iso +func (_m *MockServerClient) AttachISO(ctx context.Context, server *hcloud.Server, iso *hcloud.ISO) (*hcloud.Action, *hcloud.Response, error) { + ret := _m.Called(ctx, server, iso) + + if len(ret) == 0 { + panic("no return value specified for AttachISO") + } + + var r0 *hcloud.Action + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server, *hcloud.ISO) (*hcloud.Action, *hcloud.Response, error)); ok { + return rf(ctx, server, iso) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server, *hcloud.ISO) *hcloud.Action); ok { + r0 = rf(ctx, server, iso) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Action) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Server, *hcloud.ISO) *hcloud.Response); ok { + r1 = rf(ctx, server, iso) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Server, *hcloud.ISO) error); ok { + r2 = rf(ctx, server, iso) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_AttachISO_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AttachISO' +type MockServerClient_AttachISO_Call struct { + *mock.Call +} + +// AttachISO is a helper method to define mock.On call +// - ctx context.Context +// - server *hcloud.Server +// - iso *hcloud.ISO +func (_e *MockServerClient_Expecter) AttachISO(ctx interface{}, server interface{}, iso interface{}) *MockServerClient_AttachISO_Call { + return &MockServerClient_AttachISO_Call{Call: _e.mock.On("AttachISO", ctx, server, iso)} +} + +func (_c *MockServerClient_AttachISO_Call) Run(run func(ctx context.Context, server *hcloud.Server, iso *hcloud.ISO)) *MockServerClient_AttachISO_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Server), args[2].(*hcloud.ISO)) + }) + return _c +} + +func (_c *MockServerClient_AttachISO_Call) Return(_a0 *hcloud.Action, _a1 *hcloud.Response, _a2 error) *MockServerClient_AttachISO_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_AttachISO_Call) RunAndReturn(run func(context.Context, *hcloud.Server, *hcloud.ISO) (*hcloud.Action, *hcloud.Response, error)) *MockServerClient_AttachISO_Call { + _c.Call.Return(run) + return _c +} + +// AttachToNetwork provides a mock function with given fields: ctx, server, opts +func (_m *MockServerClient) AttachToNetwork(ctx context.Context, server *hcloud.Server, opts hcloud.ServerAttachToNetworkOpts) (*hcloud.Action, *hcloud.Response, error) { + ret := _m.Called(ctx, server, opts) + + if len(ret) == 0 { + panic("no return value specified for AttachToNetwork") + } + + var r0 *hcloud.Action + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server, hcloud.ServerAttachToNetworkOpts) (*hcloud.Action, *hcloud.Response, error)); ok { + return rf(ctx, server, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server, hcloud.ServerAttachToNetworkOpts) *hcloud.Action); ok { + r0 = rf(ctx, server, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Action) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Server, hcloud.ServerAttachToNetworkOpts) *hcloud.Response); ok { + r1 = rf(ctx, server, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Server, hcloud.ServerAttachToNetworkOpts) error); ok { + r2 = rf(ctx, server, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_AttachToNetwork_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AttachToNetwork' +type MockServerClient_AttachToNetwork_Call struct { + *mock.Call +} + +// AttachToNetwork is a helper method to define mock.On call +// - ctx context.Context +// - server *hcloud.Server +// - opts hcloud.ServerAttachToNetworkOpts +func (_e *MockServerClient_Expecter) AttachToNetwork(ctx interface{}, server interface{}, opts interface{}) *MockServerClient_AttachToNetwork_Call { + return &MockServerClient_AttachToNetwork_Call{Call: _e.mock.On("AttachToNetwork", ctx, server, opts)} +} + +func (_c *MockServerClient_AttachToNetwork_Call) Run(run func(ctx context.Context, server *hcloud.Server, opts hcloud.ServerAttachToNetworkOpts)) *MockServerClient_AttachToNetwork_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Server), args[2].(hcloud.ServerAttachToNetworkOpts)) + }) + return _c +} + +func (_c *MockServerClient_AttachToNetwork_Call) Return(_a0 *hcloud.Action, _a1 *hcloud.Response, _a2 error) *MockServerClient_AttachToNetwork_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_AttachToNetwork_Call) RunAndReturn(run func(context.Context, *hcloud.Server, hcloud.ServerAttachToNetworkOpts) (*hcloud.Action, *hcloud.Response, error)) *MockServerClient_AttachToNetwork_Call { + _c.Call.Return(run) + return _c +} + +// ChangeAliasIPs provides a mock function with given fields: ctx, server, opts +func (_m *MockServerClient) ChangeAliasIPs(ctx context.Context, server *hcloud.Server, opts hcloud.ServerChangeAliasIPsOpts) (*hcloud.Action, *hcloud.Response, error) { + ret := _m.Called(ctx, server, opts) + + if len(ret) == 0 { + panic("no return value specified for ChangeAliasIPs") + } + + var r0 *hcloud.Action + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server, hcloud.ServerChangeAliasIPsOpts) (*hcloud.Action, *hcloud.Response, error)); ok { + return rf(ctx, server, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server, hcloud.ServerChangeAliasIPsOpts) *hcloud.Action); ok { + r0 = rf(ctx, server, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Action) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Server, hcloud.ServerChangeAliasIPsOpts) *hcloud.Response); ok { + r1 = rf(ctx, server, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Server, hcloud.ServerChangeAliasIPsOpts) error); ok { + r2 = rf(ctx, server, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_ChangeAliasIPs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ChangeAliasIPs' +type MockServerClient_ChangeAliasIPs_Call struct { + *mock.Call +} + +// ChangeAliasIPs is a helper method to define mock.On call +// - ctx context.Context +// - server *hcloud.Server +// - opts hcloud.ServerChangeAliasIPsOpts +func (_e *MockServerClient_Expecter) ChangeAliasIPs(ctx interface{}, server interface{}, opts interface{}) *MockServerClient_ChangeAliasIPs_Call { + return &MockServerClient_ChangeAliasIPs_Call{Call: _e.mock.On("ChangeAliasIPs", ctx, server, opts)} +} + +func (_c *MockServerClient_ChangeAliasIPs_Call) Run(run func(ctx context.Context, server *hcloud.Server, opts hcloud.ServerChangeAliasIPsOpts)) *MockServerClient_ChangeAliasIPs_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Server), args[2].(hcloud.ServerChangeAliasIPsOpts)) + }) + return _c +} + +func (_c *MockServerClient_ChangeAliasIPs_Call) Return(_a0 *hcloud.Action, _a1 *hcloud.Response, _a2 error) *MockServerClient_ChangeAliasIPs_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_ChangeAliasIPs_Call) RunAndReturn(run func(context.Context, *hcloud.Server, hcloud.ServerChangeAliasIPsOpts) (*hcloud.Action, *hcloud.Response, error)) *MockServerClient_ChangeAliasIPs_Call { + _c.Call.Return(run) + return _c +} + +// ChangeDNSPtr provides a mock function with given fields: ctx, server, ip, ptr +func (_m *MockServerClient) ChangeDNSPtr(ctx context.Context, server *hcloud.Server, ip string, ptr *string) (*hcloud.Action, *hcloud.Response, error) { + ret := _m.Called(ctx, server, ip, ptr) + + if len(ret) == 0 { + panic("no return value specified for ChangeDNSPtr") + } + + var r0 *hcloud.Action + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server, string, *string) (*hcloud.Action, *hcloud.Response, error)); ok { + return rf(ctx, server, ip, ptr) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server, string, *string) *hcloud.Action); ok { + r0 = rf(ctx, server, ip, ptr) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Action) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Server, string, *string) *hcloud.Response); ok { + r1 = rf(ctx, server, ip, ptr) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Server, string, *string) error); ok { + r2 = rf(ctx, server, ip, ptr) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_ChangeDNSPtr_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ChangeDNSPtr' +type MockServerClient_ChangeDNSPtr_Call struct { + *mock.Call +} + +// ChangeDNSPtr is a helper method to define mock.On call +// - ctx context.Context +// - server *hcloud.Server +// - ip string +// - ptr *string +func (_e *MockServerClient_Expecter) ChangeDNSPtr(ctx interface{}, server interface{}, ip interface{}, ptr interface{}) *MockServerClient_ChangeDNSPtr_Call { + return &MockServerClient_ChangeDNSPtr_Call{Call: _e.mock.On("ChangeDNSPtr", ctx, server, ip, ptr)} +} + +func (_c *MockServerClient_ChangeDNSPtr_Call) Run(run func(ctx context.Context, server *hcloud.Server, ip string, ptr *string)) *MockServerClient_ChangeDNSPtr_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Server), args[2].(string), args[3].(*string)) + }) + return _c +} + +func (_c *MockServerClient_ChangeDNSPtr_Call) Return(_a0 *hcloud.Action, _a1 *hcloud.Response, _a2 error) *MockServerClient_ChangeDNSPtr_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_ChangeDNSPtr_Call) RunAndReturn(run func(context.Context, *hcloud.Server, string, *string) (*hcloud.Action, *hcloud.Response, error)) *MockServerClient_ChangeDNSPtr_Call { + _c.Call.Return(run) + return _c +} + +// ChangeProtection provides a mock function with given fields: ctx, server, opts +func (_m *MockServerClient) ChangeProtection(ctx context.Context, server *hcloud.Server, opts hcloud.ServerChangeProtectionOpts) (*hcloud.Action, *hcloud.Response, error) { + ret := _m.Called(ctx, server, opts) + + if len(ret) == 0 { + panic("no return value specified for ChangeProtection") + } + + var r0 *hcloud.Action + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server, hcloud.ServerChangeProtectionOpts) (*hcloud.Action, *hcloud.Response, error)); ok { + return rf(ctx, server, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server, hcloud.ServerChangeProtectionOpts) *hcloud.Action); ok { + r0 = rf(ctx, server, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Action) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Server, hcloud.ServerChangeProtectionOpts) *hcloud.Response); ok { + r1 = rf(ctx, server, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Server, hcloud.ServerChangeProtectionOpts) error); ok { + r2 = rf(ctx, server, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_ChangeProtection_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ChangeProtection' +type MockServerClient_ChangeProtection_Call struct { + *mock.Call +} + +// ChangeProtection is a helper method to define mock.On call +// - ctx context.Context +// - server *hcloud.Server +// - opts hcloud.ServerChangeProtectionOpts +func (_e *MockServerClient_Expecter) ChangeProtection(ctx interface{}, server interface{}, opts interface{}) *MockServerClient_ChangeProtection_Call { + return &MockServerClient_ChangeProtection_Call{Call: _e.mock.On("ChangeProtection", ctx, server, opts)} +} + +func (_c *MockServerClient_ChangeProtection_Call) Run(run func(ctx context.Context, server *hcloud.Server, opts hcloud.ServerChangeProtectionOpts)) *MockServerClient_ChangeProtection_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Server), args[2].(hcloud.ServerChangeProtectionOpts)) + }) + return _c +} + +func (_c *MockServerClient_ChangeProtection_Call) Return(_a0 *hcloud.Action, _a1 *hcloud.Response, _a2 error) *MockServerClient_ChangeProtection_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_ChangeProtection_Call) RunAndReturn(run func(context.Context, *hcloud.Server, hcloud.ServerChangeProtectionOpts) (*hcloud.Action, *hcloud.Response, error)) *MockServerClient_ChangeProtection_Call { + _c.Call.Return(run) + return _c +} + +// ChangeType provides a mock function with given fields: ctx, server, opts +func (_m *MockServerClient) ChangeType(ctx context.Context, server *hcloud.Server, opts hcloud.ServerChangeTypeOpts) (*hcloud.Action, *hcloud.Response, error) { + ret := _m.Called(ctx, server, opts) + + if len(ret) == 0 { + panic("no return value specified for ChangeType") + } + + var r0 *hcloud.Action + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server, hcloud.ServerChangeTypeOpts) (*hcloud.Action, *hcloud.Response, error)); ok { + return rf(ctx, server, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server, hcloud.ServerChangeTypeOpts) *hcloud.Action); ok { + r0 = rf(ctx, server, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Action) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Server, hcloud.ServerChangeTypeOpts) *hcloud.Response); ok { + r1 = rf(ctx, server, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Server, hcloud.ServerChangeTypeOpts) error); ok { + r2 = rf(ctx, server, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_ChangeType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ChangeType' +type MockServerClient_ChangeType_Call struct { + *mock.Call +} + +// ChangeType is a helper method to define mock.On call +// - ctx context.Context +// - server *hcloud.Server +// - opts hcloud.ServerChangeTypeOpts +func (_e *MockServerClient_Expecter) ChangeType(ctx interface{}, server interface{}, opts interface{}) *MockServerClient_ChangeType_Call { + return &MockServerClient_ChangeType_Call{Call: _e.mock.On("ChangeType", ctx, server, opts)} +} + +func (_c *MockServerClient_ChangeType_Call) Run(run func(ctx context.Context, server *hcloud.Server, opts hcloud.ServerChangeTypeOpts)) *MockServerClient_ChangeType_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Server), args[2].(hcloud.ServerChangeTypeOpts)) + }) + return _c +} + +func (_c *MockServerClient_ChangeType_Call) Return(_a0 *hcloud.Action, _a1 *hcloud.Response, _a2 error) *MockServerClient_ChangeType_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_ChangeType_Call) RunAndReturn(run func(context.Context, *hcloud.Server, hcloud.ServerChangeTypeOpts) (*hcloud.Action, *hcloud.Response, error)) *MockServerClient_ChangeType_Call { + _c.Call.Return(run) + return _c +} + +// Create provides a mock function with given fields: ctx, opts +func (_m *MockServerClient) Create(ctx context.Context, opts hcloud.ServerCreateOpts) (hcloud.ServerCreateResult, *hcloud.Response, error) { + ret := _m.Called(ctx, opts) + + if len(ret) == 0 { + panic("no return value specified for Create") + } + + var r0 hcloud.ServerCreateResult + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, hcloud.ServerCreateOpts) (hcloud.ServerCreateResult, *hcloud.Response, error)); ok { + return rf(ctx, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, hcloud.ServerCreateOpts) hcloud.ServerCreateResult); ok { + r0 = rf(ctx, opts) + } else { + r0 = ret.Get(0).(hcloud.ServerCreateResult) + } + + if rf, ok := ret.Get(1).(func(context.Context, hcloud.ServerCreateOpts) *hcloud.Response); ok { + r1 = rf(ctx, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, hcloud.ServerCreateOpts) error); ok { + r2 = rf(ctx, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type MockServerClient_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - opts hcloud.ServerCreateOpts +func (_e *MockServerClient_Expecter) Create(ctx interface{}, opts interface{}) *MockServerClient_Create_Call { + return &MockServerClient_Create_Call{Call: _e.mock.On("Create", ctx, opts)} +} + +func (_c *MockServerClient_Create_Call) Run(run func(ctx context.Context, opts hcloud.ServerCreateOpts)) *MockServerClient_Create_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(hcloud.ServerCreateOpts)) + }) + return _c +} + +func (_c *MockServerClient_Create_Call) Return(_a0 hcloud.ServerCreateResult, _a1 *hcloud.Response, _a2 error) *MockServerClient_Create_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_Create_Call) RunAndReturn(run func(context.Context, hcloud.ServerCreateOpts) (hcloud.ServerCreateResult, *hcloud.Response, error)) *MockServerClient_Create_Call { + _c.Call.Return(run) + return _c +} + +// CreateImage provides a mock function with given fields: ctx, server, opts +func (_m *MockServerClient) CreateImage(ctx context.Context, server *hcloud.Server, opts *hcloud.ServerCreateImageOpts) (hcloud.ServerCreateImageResult, *hcloud.Response, error) { + ret := _m.Called(ctx, server, opts) + + if len(ret) == 0 { + panic("no return value specified for CreateImage") + } + + var r0 hcloud.ServerCreateImageResult + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server, *hcloud.ServerCreateImageOpts) (hcloud.ServerCreateImageResult, *hcloud.Response, error)); ok { + return rf(ctx, server, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server, *hcloud.ServerCreateImageOpts) hcloud.ServerCreateImageResult); ok { + r0 = rf(ctx, server, opts) + } else { + r0 = ret.Get(0).(hcloud.ServerCreateImageResult) + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Server, *hcloud.ServerCreateImageOpts) *hcloud.Response); ok { + r1 = rf(ctx, server, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Server, *hcloud.ServerCreateImageOpts) error); ok { + r2 = rf(ctx, server, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_CreateImage_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateImage' +type MockServerClient_CreateImage_Call struct { + *mock.Call +} + +// CreateImage is a helper method to define mock.On call +// - ctx context.Context +// - server *hcloud.Server +// - opts *hcloud.ServerCreateImageOpts +func (_e *MockServerClient_Expecter) CreateImage(ctx interface{}, server interface{}, opts interface{}) *MockServerClient_CreateImage_Call { + return &MockServerClient_CreateImage_Call{Call: _e.mock.On("CreateImage", ctx, server, opts)} +} + +func (_c *MockServerClient_CreateImage_Call) Run(run func(ctx context.Context, server *hcloud.Server, opts *hcloud.ServerCreateImageOpts)) *MockServerClient_CreateImage_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Server), args[2].(*hcloud.ServerCreateImageOpts)) + }) + return _c +} + +func (_c *MockServerClient_CreateImage_Call) Return(_a0 hcloud.ServerCreateImageResult, _a1 *hcloud.Response, _a2 error) *MockServerClient_CreateImage_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_CreateImage_Call) RunAndReturn(run func(context.Context, *hcloud.Server, *hcloud.ServerCreateImageOpts) (hcloud.ServerCreateImageResult, *hcloud.Response, error)) *MockServerClient_CreateImage_Call { + _c.Call.Return(run) + return _c +} + +// Delete provides a mock function with given fields: ctx, server +func (_m *MockServerClient) Delete(ctx context.Context, server *hcloud.Server) (*hcloud.Response, error) { + ret := _m.Called(ctx, server) + + if len(ret) == 0 { + panic("no return value specified for Delete") + } + + var r0 *hcloud.Response + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server) (*hcloud.Response, error)); ok { + return rf(ctx, server) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server) *hcloud.Response); ok { + r0 = rf(ctx, server) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Server) error); ok { + r1 = rf(ctx, server) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockServerClient_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' +type MockServerClient_Delete_Call struct { + *mock.Call +} + +// Delete is a helper method to define mock.On call +// - ctx context.Context +// - server *hcloud.Server +func (_e *MockServerClient_Expecter) Delete(ctx interface{}, server interface{}) *MockServerClient_Delete_Call { + return &MockServerClient_Delete_Call{Call: _e.mock.On("Delete", ctx, server)} +} + +func (_c *MockServerClient_Delete_Call) Run(run func(ctx context.Context, server *hcloud.Server)) *MockServerClient_Delete_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Server)) + }) + return _c +} + +func (_c *MockServerClient_Delete_Call) Return(_a0 *hcloud.Response, _a1 error) *MockServerClient_Delete_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockServerClient_Delete_Call) RunAndReturn(run func(context.Context, *hcloud.Server) (*hcloud.Response, error)) *MockServerClient_Delete_Call { + _c.Call.Return(run) + return _c +} + +// DeleteWithResult provides a mock function with given fields: ctx, server +func (_m *MockServerClient) DeleteWithResult(ctx context.Context, server *hcloud.Server) (*hcloud.ServerDeleteResult, *hcloud.Response, error) { + ret := _m.Called(ctx, server) + + if len(ret) == 0 { + panic("no return value specified for DeleteWithResult") + } + + var r0 *hcloud.ServerDeleteResult + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server) (*hcloud.ServerDeleteResult, *hcloud.Response, error)); ok { + return rf(ctx, server) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server) *hcloud.ServerDeleteResult); ok { + r0 = rf(ctx, server) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.ServerDeleteResult) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Server) *hcloud.Response); ok { + r1 = rf(ctx, server) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Server) error); ok { + r2 = rf(ctx, server) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_DeleteWithResult_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteWithResult' +type MockServerClient_DeleteWithResult_Call struct { + *mock.Call +} + +// DeleteWithResult is a helper method to define mock.On call +// - ctx context.Context +// - server *hcloud.Server +func (_e *MockServerClient_Expecter) DeleteWithResult(ctx interface{}, server interface{}) *MockServerClient_DeleteWithResult_Call { + return &MockServerClient_DeleteWithResult_Call{Call: _e.mock.On("DeleteWithResult", ctx, server)} +} + +func (_c *MockServerClient_DeleteWithResult_Call) Run(run func(ctx context.Context, server *hcloud.Server)) *MockServerClient_DeleteWithResult_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Server)) + }) + return _c +} + +func (_c *MockServerClient_DeleteWithResult_Call) Return(_a0 *hcloud.ServerDeleteResult, _a1 *hcloud.Response, _a2 error) *MockServerClient_DeleteWithResult_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_DeleteWithResult_Call) RunAndReturn(run func(context.Context, *hcloud.Server) (*hcloud.ServerDeleteResult, *hcloud.Response, error)) *MockServerClient_DeleteWithResult_Call { + _c.Call.Return(run) + return _c +} + +// DetachFromNetwork provides a mock function with given fields: ctx, server, opts +func (_m *MockServerClient) DetachFromNetwork(ctx context.Context, server *hcloud.Server, opts hcloud.ServerDetachFromNetworkOpts) (*hcloud.Action, *hcloud.Response, error) { + ret := _m.Called(ctx, server, opts) + + if len(ret) == 0 { + panic("no return value specified for DetachFromNetwork") + } + + var r0 *hcloud.Action + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server, hcloud.ServerDetachFromNetworkOpts) (*hcloud.Action, *hcloud.Response, error)); ok { + return rf(ctx, server, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server, hcloud.ServerDetachFromNetworkOpts) *hcloud.Action); ok { + r0 = rf(ctx, server, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Action) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Server, hcloud.ServerDetachFromNetworkOpts) *hcloud.Response); ok { + r1 = rf(ctx, server, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Server, hcloud.ServerDetachFromNetworkOpts) error); ok { + r2 = rf(ctx, server, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_DetachFromNetwork_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DetachFromNetwork' +type MockServerClient_DetachFromNetwork_Call struct { + *mock.Call +} + +// DetachFromNetwork is a helper method to define mock.On call +// - ctx context.Context +// - server *hcloud.Server +// - opts hcloud.ServerDetachFromNetworkOpts +func (_e *MockServerClient_Expecter) DetachFromNetwork(ctx interface{}, server interface{}, opts interface{}) *MockServerClient_DetachFromNetwork_Call { + return &MockServerClient_DetachFromNetwork_Call{Call: _e.mock.On("DetachFromNetwork", ctx, server, opts)} +} + +func (_c *MockServerClient_DetachFromNetwork_Call) Run(run func(ctx context.Context, server *hcloud.Server, opts hcloud.ServerDetachFromNetworkOpts)) *MockServerClient_DetachFromNetwork_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Server), args[2].(hcloud.ServerDetachFromNetworkOpts)) + }) + return _c +} + +func (_c *MockServerClient_DetachFromNetwork_Call) Return(_a0 *hcloud.Action, _a1 *hcloud.Response, _a2 error) *MockServerClient_DetachFromNetwork_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_DetachFromNetwork_Call) RunAndReturn(run func(context.Context, *hcloud.Server, hcloud.ServerDetachFromNetworkOpts) (*hcloud.Action, *hcloud.Response, error)) *MockServerClient_DetachFromNetwork_Call { + _c.Call.Return(run) + return _c +} + +// DetachISO provides a mock function with given fields: ctx, server +func (_m *MockServerClient) DetachISO(ctx context.Context, server *hcloud.Server) (*hcloud.Action, *hcloud.Response, error) { + ret := _m.Called(ctx, server) + + if len(ret) == 0 { + panic("no return value specified for DetachISO") + } + + var r0 *hcloud.Action + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server) (*hcloud.Action, *hcloud.Response, error)); ok { + return rf(ctx, server) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server) *hcloud.Action); ok { + r0 = rf(ctx, server) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Action) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Server) *hcloud.Response); ok { + r1 = rf(ctx, server) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Server) error); ok { + r2 = rf(ctx, server) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_DetachISO_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DetachISO' +type MockServerClient_DetachISO_Call struct { + *mock.Call +} + +// DetachISO is a helper method to define mock.On call +// - ctx context.Context +// - server *hcloud.Server +func (_e *MockServerClient_Expecter) DetachISO(ctx interface{}, server interface{}) *MockServerClient_DetachISO_Call { + return &MockServerClient_DetachISO_Call{Call: _e.mock.On("DetachISO", ctx, server)} +} + +func (_c *MockServerClient_DetachISO_Call) Run(run func(ctx context.Context, server *hcloud.Server)) *MockServerClient_DetachISO_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Server)) + }) + return _c +} + +func (_c *MockServerClient_DetachISO_Call) Return(_a0 *hcloud.Action, _a1 *hcloud.Response, _a2 error) *MockServerClient_DetachISO_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_DetachISO_Call) RunAndReturn(run func(context.Context, *hcloud.Server) (*hcloud.Action, *hcloud.Response, error)) *MockServerClient_DetachISO_Call { + _c.Call.Return(run) + return _c +} + +// DisableBackup provides a mock function with given fields: ctx, server +func (_m *MockServerClient) DisableBackup(ctx context.Context, server *hcloud.Server) (*hcloud.Action, *hcloud.Response, error) { + ret := _m.Called(ctx, server) + + if len(ret) == 0 { + panic("no return value specified for DisableBackup") + } + + var r0 *hcloud.Action + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server) (*hcloud.Action, *hcloud.Response, error)); ok { + return rf(ctx, server) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server) *hcloud.Action); ok { + r0 = rf(ctx, server) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Action) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Server) *hcloud.Response); ok { + r1 = rf(ctx, server) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Server) error); ok { + r2 = rf(ctx, server) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_DisableBackup_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DisableBackup' +type MockServerClient_DisableBackup_Call struct { + *mock.Call +} + +// DisableBackup is a helper method to define mock.On call +// - ctx context.Context +// - server *hcloud.Server +func (_e *MockServerClient_Expecter) DisableBackup(ctx interface{}, server interface{}) *MockServerClient_DisableBackup_Call { + return &MockServerClient_DisableBackup_Call{Call: _e.mock.On("DisableBackup", ctx, server)} +} + +func (_c *MockServerClient_DisableBackup_Call) Run(run func(ctx context.Context, server *hcloud.Server)) *MockServerClient_DisableBackup_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Server)) + }) + return _c +} + +func (_c *MockServerClient_DisableBackup_Call) Return(_a0 *hcloud.Action, _a1 *hcloud.Response, _a2 error) *MockServerClient_DisableBackup_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_DisableBackup_Call) RunAndReturn(run func(context.Context, *hcloud.Server) (*hcloud.Action, *hcloud.Response, error)) *MockServerClient_DisableBackup_Call { + _c.Call.Return(run) + return _c +} + +// DisableRescue provides a mock function with given fields: ctx, server +func (_m *MockServerClient) DisableRescue(ctx context.Context, server *hcloud.Server) (*hcloud.Action, *hcloud.Response, error) { + ret := _m.Called(ctx, server) + + if len(ret) == 0 { + panic("no return value specified for DisableRescue") + } + + var r0 *hcloud.Action + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server) (*hcloud.Action, *hcloud.Response, error)); ok { + return rf(ctx, server) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server) *hcloud.Action); ok { + r0 = rf(ctx, server) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Action) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Server) *hcloud.Response); ok { + r1 = rf(ctx, server) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Server) error); ok { + r2 = rf(ctx, server) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_DisableRescue_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DisableRescue' +type MockServerClient_DisableRescue_Call struct { + *mock.Call +} + +// DisableRescue is a helper method to define mock.On call +// - ctx context.Context +// - server *hcloud.Server +func (_e *MockServerClient_Expecter) DisableRescue(ctx interface{}, server interface{}) *MockServerClient_DisableRescue_Call { + return &MockServerClient_DisableRescue_Call{Call: _e.mock.On("DisableRescue", ctx, server)} +} + +func (_c *MockServerClient_DisableRescue_Call) Run(run func(ctx context.Context, server *hcloud.Server)) *MockServerClient_DisableRescue_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Server)) + }) + return _c +} + +func (_c *MockServerClient_DisableRescue_Call) Return(_a0 *hcloud.Action, _a1 *hcloud.Response, _a2 error) *MockServerClient_DisableRescue_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_DisableRescue_Call) RunAndReturn(run func(context.Context, *hcloud.Server) (*hcloud.Action, *hcloud.Response, error)) *MockServerClient_DisableRescue_Call { + _c.Call.Return(run) + return _c +} + +// EnableBackup provides a mock function with given fields: ctx, server, window +func (_m *MockServerClient) EnableBackup(ctx context.Context, server *hcloud.Server, window string) (*hcloud.Action, *hcloud.Response, error) { + ret := _m.Called(ctx, server, window) + + if len(ret) == 0 { + panic("no return value specified for EnableBackup") + } + + var r0 *hcloud.Action + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server, string) (*hcloud.Action, *hcloud.Response, error)); ok { + return rf(ctx, server, window) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server, string) *hcloud.Action); ok { + r0 = rf(ctx, server, window) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Action) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Server, string) *hcloud.Response); ok { + r1 = rf(ctx, server, window) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Server, string) error); ok { + r2 = rf(ctx, server, window) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_EnableBackup_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EnableBackup' +type MockServerClient_EnableBackup_Call struct { + *mock.Call +} + +// EnableBackup is a helper method to define mock.On call +// - ctx context.Context +// - server *hcloud.Server +// - window string +func (_e *MockServerClient_Expecter) EnableBackup(ctx interface{}, server interface{}, window interface{}) *MockServerClient_EnableBackup_Call { + return &MockServerClient_EnableBackup_Call{Call: _e.mock.On("EnableBackup", ctx, server, window)} +} + +func (_c *MockServerClient_EnableBackup_Call) Run(run func(ctx context.Context, server *hcloud.Server, window string)) *MockServerClient_EnableBackup_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Server), args[2].(string)) + }) + return _c +} + +func (_c *MockServerClient_EnableBackup_Call) Return(_a0 *hcloud.Action, _a1 *hcloud.Response, _a2 error) *MockServerClient_EnableBackup_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_EnableBackup_Call) RunAndReturn(run func(context.Context, *hcloud.Server, string) (*hcloud.Action, *hcloud.Response, error)) *MockServerClient_EnableBackup_Call { + _c.Call.Return(run) + return _c +} + +// EnableRescue provides a mock function with given fields: ctx, server, opts +func (_m *MockServerClient) EnableRescue(ctx context.Context, server *hcloud.Server, opts hcloud.ServerEnableRescueOpts) (hcloud.ServerEnableRescueResult, *hcloud.Response, error) { + ret := _m.Called(ctx, server, opts) + + if len(ret) == 0 { + panic("no return value specified for EnableRescue") + } + + var r0 hcloud.ServerEnableRescueResult + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server, hcloud.ServerEnableRescueOpts) (hcloud.ServerEnableRescueResult, *hcloud.Response, error)); ok { + return rf(ctx, server, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server, hcloud.ServerEnableRescueOpts) hcloud.ServerEnableRescueResult); ok { + r0 = rf(ctx, server, opts) + } else { + r0 = ret.Get(0).(hcloud.ServerEnableRescueResult) + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Server, hcloud.ServerEnableRescueOpts) *hcloud.Response); ok { + r1 = rf(ctx, server, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Server, hcloud.ServerEnableRescueOpts) error); ok { + r2 = rf(ctx, server, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_EnableRescue_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EnableRescue' +type MockServerClient_EnableRescue_Call struct { + *mock.Call +} + +// EnableRescue is a helper method to define mock.On call +// - ctx context.Context +// - server *hcloud.Server +// - opts hcloud.ServerEnableRescueOpts +func (_e *MockServerClient_Expecter) EnableRescue(ctx interface{}, server interface{}, opts interface{}) *MockServerClient_EnableRescue_Call { + return &MockServerClient_EnableRescue_Call{Call: _e.mock.On("EnableRescue", ctx, server, opts)} +} + +func (_c *MockServerClient_EnableRescue_Call) Run(run func(ctx context.Context, server *hcloud.Server, opts hcloud.ServerEnableRescueOpts)) *MockServerClient_EnableRescue_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Server), args[2].(hcloud.ServerEnableRescueOpts)) + }) + return _c +} + +func (_c *MockServerClient_EnableRescue_Call) Return(_a0 hcloud.ServerEnableRescueResult, _a1 *hcloud.Response, _a2 error) *MockServerClient_EnableRescue_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_EnableRescue_Call) RunAndReturn(run func(context.Context, *hcloud.Server, hcloud.ServerEnableRescueOpts) (hcloud.ServerEnableRescueResult, *hcloud.Response, error)) *MockServerClient_EnableRescue_Call { + _c.Call.Return(run) + return _c +} + +// Get provides a mock function with given fields: ctx, idOrName +func (_m *MockServerClient) Get(ctx context.Context, idOrName string) (*hcloud.Server, *hcloud.Response, error) { + ret := _m.Called(ctx, idOrName) + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 *hcloud.Server + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*hcloud.Server, *hcloud.Response, error)); ok { + return rf(ctx, idOrName) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *hcloud.Server); ok { + r0 = rf(ctx, idOrName) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Server) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) *hcloud.Response); ok { + r1 = rf(ctx, idOrName) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, string) error); ok { + r2 = rf(ctx, idOrName) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type MockServerClient_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +// - ctx context.Context +// - idOrName string +func (_e *MockServerClient_Expecter) Get(ctx interface{}, idOrName interface{}) *MockServerClient_Get_Call { + return &MockServerClient_Get_Call{Call: _e.mock.On("Get", ctx, idOrName)} +} + +func (_c *MockServerClient_Get_Call) Run(run func(ctx context.Context, idOrName string)) *MockServerClient_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockServerClient_Get_Call) Return(_a0 *hcloud.Server, _a1 *hcloud.Response, _a2 error) *MockServerClient_Get_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_Get_Call) RunAndReturn(run func(context.Context, string) (*hcloud.Server, *hcloud.Response, error)) *MockServerClient_Get_Call { + _c.Call.Return(run) + return _c +} + +// GetByID provides a mock function with given fields: ctx, id +func (_m *MockServerClient) GetByID(ctx context.Context, id int64) (*hcloud.Server, *hcloud.Response, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for GetByID") + } + + var r0 *hcloud.Server + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, int64) (*hcloud.Server, *hcloud.Response, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, int64) *hcloud.Server); ok { + r0 = rf(ctx, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Server) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, int64) *hcloud.Response); ok { + r1 = rf(ctx, id) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, int64) error); ok { + r2 = rf(ctx, id) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_GetByID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByID' +type MockServerClient_GetByID_Call struct { + *mock.Call +} + +// GetByID is a helper method to define mock.On call +// - ctx context.Context +// - id int64 +func (_e *MockServerClient_Expecter) GetByID(ctx interface{}, id interface{}) *MockServerClient_GetByID_Call { + return &MockServerClient_GetByID_Call{Call: _e.mock.On("GetByID", ctx, id)} +} + +func (_c *MockServerClient_GetByID_Call) Run(run func(ctx context.Context, id int64)) *MockServerClient_GetByID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(int64)) + }) + return _c +} + +func (_c *MockServerClient_GetByID_Call) Return(_a0 *hcloud.Server, _a1 *hcloud.Response, _a2 error) *MockServerClient_GetByID_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_GetByID_Call) RunAndReturn(run func(context.Context, int64) (*hcloud.Server, *hcloud.Response, error)) *MockServerClient_GetByID_Call { + _c.Call.Return(run) + return _c +} + +// GetByName provides a mock function with given fields: ctx, name +func (_m *MockServerClient) GetByName(ctx context.Context, name string) (*hcloud.Server, *hcloud.Response, error) { + ret := _m.Called(ctx, name) + + if len(ret) == 0 { + panic("no return value specified for GetByName") + } + + var r0 *hcloud.Server + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*hcloud.Server, *hcloud.Response, error)); ok { + return rf(ctx, name) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *hcloud.Server); ok { + r0 = rf(ctx, name) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Server) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) *hcloud.Response); ok { + r1 = rf(ctx, name) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, string) error); ok { + r2 = rf(ctx, name) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_GetByName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByName' +type MockServerClient_GetByName_Call struct { + *mock.Call +} + +// GetByName is a helper method to define mock.On call +// - ctx context.Context +// - name string +func (_e *MockServerClient_Expecter) GetByName(ctx interface{}, name interface{}) *MockServerClient_GetByName_Call { + return &MockServerClient_GetByName_Call{Call: _e.mock.On("GetByName", ctx, name)} +} + +func (_c *MockServerClient_GetByName_Call) Run(run func(ctx context.Context, name string)) *MockServerClient_GetByName_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockServerClient_GetByName_Call) Return(_a0 *hcloud.Server, _a1 *hcloud.Response, _a2 error) *MockServerClient_GetByName_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_GetByName_Call) RunAndReturn(run func(context.Context, string) (*hcloud.Server, *hcloud.Response, error)) *MockServerClient_GetByName_Call { + _c.Call.Return(run) + return _c +} + +// GetMetrics provides a mock function with given fields: ctx, server, opts +func (_m *MockServerClient) GetMetrics(ctx context.Context, server *hcloud.Server, opts hcloud.ServerGetMetricsOpts) (*hcloud.ServerMetrics, *hcloud.Response, error) { + ret := _m.Called(ctx, server, opts) + + if len(ret) == 0 { + panic("no return value specified for GetMetrics") + } + + var r0 *hcloud.ServerMetrics + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server, hcloud.ServerGetMetricsOpts) (*hcloud.ServerMetrics, *hcloud.Response, error)); ok { + return rf(ctx, server, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server, hcloud.ServerGetMetricsOpts) *hcloud.ServerMetrics); ok { + r0 = rf(ctx, server, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.ServerMetrics) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Server, hcloud.ServerGetMetricsOpts) *hcloud.Response); ok { + r1 = rf(ctx, server, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Server, hcloud.ServerGetMetricsOpts) error); ok { + r2 = rf(ctx, server, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_GetMetrics_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetMetrics' +type MockServerClient_GetMetrics_Call struct { + *mock.Call +} + +// GetMetrics is a helper method to define mock.On call +// - ctx context.Context +// - server *hcloud.Server +// - opts hcloud.ServerGetMetricsOpts +func (_e *MockServerClient_Expecter) GetMetrics(ctx interface{}, server interface{}, opts interface{}) *MockServerClient_GetMetrics_Call { + return &MockServerClient_GetMetrics_Call{Call: _e.mock.On("GetMetrics", ctx, server, opts)} +} + +func (_c *MockServerClient_GetMetrics_Call) Run(run func(ctx context.Context, server *hcloud.Server, opts hcloud.ServerGetMetricsOpts)) *MockServerClient_GetMetrics_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Server), args[2].(hcloud.ServerGetMetricsOpts)) + }) + return _c +} + +func (_c *MockServerClient_GetMetrics_Call) Return(_a0 *hcloud.ServerMetrics, _a1 *hcloud.Response, _a2 error) *MockServerClient_GetMetrics_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_GetMetrics_Call) RunAndReturn(run func(context.Context, *hcloud.Server, hcloud.ServerGetMetricsOpts) (*hcloud.ServerMetrics, *hcloud.Response, error)) *MockServerClient_GetMetrics_Call { + _c.Call.Return(run) + return _c +} + +// List provides a mock function with given fields: ctx, opts +func (_m *MockServerClient) List(ctx context.Context, opts hcloud.ServerListOpts) ([]*hcloud.Server, *hcloud.Response, error) { + ret := _m.Called(ctx, opts) + + if len(ret) == 0 { + panic("no return value specified for List") + } + + var r0 []*hcloud.Server + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, hcloud.ServerListOpts) ([]*hcloud.Server, *hcloud.Response, error)); ok { + return rf(ctx, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, hcloud.ServerListOpts) []*hcloud.Server); ok { + r0 = rf(ctx, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*hcloud.Server) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, hcloud.ServerListOpts) *hcloud.Response); ok { + r1 = rf(ctx, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, hcloud.ServerListOpts) error); ok { + r2 = rf(ctx, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' +type MockServerClient_List_Call struct { + *mock.Call +} + +// List is a helper method to define mock.On call +// - ctx context.Context +// - opts hcloud.ServerListOpts +func (_e *MockServerClient_Expecter) List(ctx interface{}, opts interface{}) *MockServerClient_List_Call { + return &MockServerClient_List_Call{Call: _e.mock.On("List", ctx, opts)} +} + +func (_c *MockServerClient_List_Call) Run(run func(ctx context.Context, opts hcloud.ServerListOpts)) *MockServerClient_List_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(hcloud.ServerListOpts)) + }) + return _c +} + +func (_c *MockServerClient_List_Call) Return(_a0 []*hcloud.Server, _a1 *hcloud.Response, _a2 error) *MockServerClient_List_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_List_Call) RunAndReturn(run func(context.Context, hcloud.ServerListOpts) ([]*hcloud.Server, *hcloud.Response, error)) *MockServerClient_List_Call { + _c.Call.Return(run) + return _c +} + +// Poweroff provides a mock function with given fields: ctx, server +func (_m *MockServerClient) Poweroff(ctx context.Context, server *hcloud.Server) (*hcloud.Action, *hcloud.Response, error) { + ret := _m.Called(ctx, server) + + if len(ret) == 0 { + panic("no return value specified for Poweroff") + } + + var r0 *hcloud.Action + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server) (*hcloud.Action, *hcloud.Response, error)); ok { + return rf(ctx, server) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server) *hcloud.Action); ok { + r0 = rf(ctx, server) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Action) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Server) *hcloud.Response); ok { + r1 = rf(ctx, server) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Server) error); ok { + r2 = rf(ctx, server) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_Poweroff_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Poweroff' +type MockServerClient_Poweroff_Call struct { + *mock.Call +} + +// Poweroff is a helper method to define mock.On call +// - ctx context.Context +// - server *hcloud.Server +func (_e *MockServerClient_Expecter) Poweroff(ctx interface{}, server interface{}) *MockServerClient_Poweroff_Call { + return &MockServerClient_Poweroff_Call{Call: _e.mock.On("Poweroff", ctx, server)} +} + +func (_c *MockServerClient_Poweroff_Call) Run(run func(ctx context.Context, server *hcloud.Server)) *MockServerClient_Poweroff_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Server)) + }) + return _c +} + +func (_c *MockServerClient_Poweroff_Call) Return(_a0 *hcloud.Action, _a1 *hcloud.Response, _a2 error) *MockServerClient_Poweroff_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_Poweroff_Call) RunAndReturn(run func(context.Context, *hcloud.Server) (*hcloud.Action, *hcloud.Response, error)) *MockServerClient_Poweroff_Call { + _c.Call.Return(run) + return _c +} + +// Poweron provides a mock function with given fields: ctx, server +func (_m *MockServerClient) Poweron(ctx context.Context, server *hcloud.Server) (*hcloud.Action, *hcloud.Response, error) { + ret := _m.Called(ctx, server) + + if len(ret) == 0 { + panic("no return value specified for Poweron") + } + + var r0 *hcloud.Action + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server) (*hcloud.Action, *hcloud.Response, error)); ok { + return rf(ctx, server) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server) *hcloud.Action); ok { + r0 = rf(ctx, server) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Action) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Server) *hcloud.Response); ok { + r1 = rf(ctx, server) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Server) error); ok { + r2 = rf(ctx, server) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_Poweron_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Poweron' +type MockServerClient_Poweron_Call struct { + *mock.Call +} + +// Poweron is a helper method to define mock.On call +// - ctx context.Context +// - server *hcloud.Server +func (_e *MockServerClient_Expecter) Poweron(ctx interface{}, server interface{}) *MockServerClient_Poweron_Call { + return &MockServerClient_Poweron_Call{Call: _e.mock.On("Poweron", ctx, server)} +} + +func (_c *MockServerClient_Poweron_Call) Run(run func(ctx context.Context, server *hcloud.Server)) *MockServerClient_Poweron_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Server)) + }) + return _c +} + +func (_c *MockServerClient_Poweron_Call) Return(_a0 *hcloud.Action, _a1 *hcloud.Response, _a2 error) *MockServerClient_Poweron_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_Poweron_Call) RunAndReturn(run func(context.Context, *hcloud.Server) (*hcloud.Action, *hcloud.Response, error)) *MockServerClient_Poweron_Call { + _c.Call.Return(run) + return _c +} + +// Reboot provides a mock function with given fields: ctx, server +func (_m *MockServerClient) Reboot(ctx context.Context, server *hcloud.Server) (*hcloud.Action, *hcloud.Response, error) { + ret := _m.Called(ctx, server) + + if len(ret) == 0 { + panic("no return value specified for Reboot") + } + + var r0 *hcloud.Action + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server) (*hcloud.Action, *hcloud.Response, error)); ok { + return rf(ctx, server) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server) *hcloud.Action); ok { + r0 = rf(ctx, server) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Action) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Server) *hcloud.Response); ok { + r1 = rf(ctx, server) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Server) error); ok { + r2 = rf(ctx, server) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_Reboot_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Reboot' +type MockServerClient_Reboot_Call struct { + *mock.Call +} + +// Reboot is a helper method to define mock.On call +// - ctx context.Context +// - server *hcloud.Server +func (_e *MockServerClient_Expecter) Reboot(ctx interface{}, server interface{}) *MockServerClient_Reboot_Call { + return &MockServerClient_Reboot_Call{Call: _e.mock.On("Reboot", ctx, server)} +} + +func (_c *MockServerClient_Reboot_Call) Run(run func(ctx context.Context, server *hcloud.Server)) *MockServerClient_Reboot_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Server)) + }) + return _c +} + +func (_c *MockServerClient_Reboot_Call) Return(_a0 *hcloud.Action, _a1 *hcloud.Response, _a2 error) *MockServerClient_Reboot_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_Reboot_Call) RunAndReturn(run func(context.Context, *hcloud.Server) (*hcloud.Action, *hcloud.Response, error)) *MockServerClient_Reboot_Call { + _c.Call.Return(run) + return _c +} + +// Rebuild provides a mock function with given fields: ctx, server, opts +func (_m *MockServerClient) Rebuild(ctx context.Context, server *hcloud.Server, opts hcloud.ServerRebuildOpts) (*hcloud.Action, *hcloud.Response, error) { + ret := _m.Called(ctx, server, opts) + + if len(ret) == 0 { + panic("no return value specified for Rebuild") + } + + var r0 *hcloud.Action + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server, hcloud.ServerRebuildOpts) (*hcloud.Action, *hcloud.Response, error)); ok { + return rf(ctx, server, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server, hcloud.ServerRebuildOpts) *hcloud.Action); ok { + r0 = rf(ctx, server, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Action) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Server, hcloud.ServerRebuildOpts) *hcloud.Response); ok { + r1 = rf(ctx, server, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Server, hcloud.ServerRebuildOpts) error); ok { + r2 = rf(ctx, server, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_Rebuild_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Rebuild' +type MockServerClient_Rebuild_Call struct { + *mock.Call +} + +// Rebuild is a helper method to define mock.On call +// - ctx context.Context +// - server *hcloud.Server +// - opts hcloud.ServerRebuildOpts +func (_e *MockServerClient_Expecter) Rebuild(ctx interface{}, server interface{}, opts interface{}) *MockServerClient_Rebuild_Call { + return &MockServerClient_Rebuild_Call{Call: _e.mock.On("Rebuild", ctx, server, opts)} +} + +func (_c *MockServerClient_Rebuild_Call) Run(run func(ctx context.Context, server *hcloud.Server, opts hcloud.ServerRebuildOpts)) *MockServerClient_Rebuild_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Server), args[2].(hcloud.ServerRebuildOpts)) + }) + return _c +} + +func (_c *MockServerClient_Rebuild_Call) Return(_a0 *hcloud.Action, _a1 *hcloud.Response, _a2 error) *MockServerClient_Rebuild_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_Rebuild_Call) RunAndReturn(run func(context.Context, *hcloud.Server, hcloud.ServerRebuildOpts) (*hcloud.Action, *hcloud.Response, error)) *MockServerClient_Rebuild_Call { + _c.Call.Return(run) + return _c +} + +// RebuildWithResult provides a mock function with given fields: ctx, server, opts +func (_m *MockServerClient) RebuildWithResult(ctx context.Context, server *hcloud.Server, opts hcloud.ServerRebuildOpts) (hcloud.ServerRebuildResult, *hcloud.Response, error) { + ret := _m.Called(ctx, server, opts) + + if len(ret) == 0 { + panic("no return value specified for RebuildWithResult") + } + + var r0 hcloud.ServerRebuildResult + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server, hcloud.ServerRebuildOpts) (hcloud.ServerRebuildResult, *hcloud.Response, error)); ok { + return rf(ctx, server, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server, hcloud.ServerRebuildOpts) hcloud.ServerRebuildResult); ok { + r0 = rf(ctx, server, opts) + } else { + r0 = ret.Get(0).(hcloud.ServerRebuildResult) + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Server, hcloud.ServerRebuildOpts) *hcloud.Response); ok { + r1 = rf(ctx, server, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Server, hcloud.ServerRebuildOpts) error); ok { + r2 = rf(ctx, server, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_RebuildWithResult_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RebuildWithResult' +type MockServerClient_RebuildWithResult_Call struct { + *mock.Call +} + +// RebuildWithResult is a helper method to define mock.On call +// - ctx context.Context +// - server *hcloud.Server +// - opts hcloud.ServerRebuildOpts +func (_e *MockServerClient_Expecter) RebuildWithResult(ctx interface{}, server interface{}, opts interface{}) *MockServerClient_RebuildWithResult_Call { + return &MockServerClient_RebuildWithResult_Call{Call: _e.mock.On("RebuildWithResult", ctx, server, opts)} +} + +func (_c *MockServerClient_RebuildWithResult_Call) Run(run func(ctx context.Context, server *hcloud.Server, opts hcloud.ServerRebuildOpts)) *MockServerClient_RebuildWithResult_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Server), args[2].(hcloud.ServerRebuildOpts)) + }) + return _c +} + +func (_c *MockServerClient_RebuildWithResult_Call) Return(_a0 hcloud.ServerRebuildResult, _a1 *hcloud.Response, _a2 error) *MockServerClient_RebuildWithResult_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_RebuildWithResult_Call) RunAndReturn(run func(context.Context, *hcloud.Server, hcloud.ServerRebuildOpts) (hcloud.ServerRebuildResult, *hcloud.Response, error)) *MockServerClient_RebuildWithResult_Call { + _c.Call.Return(run) + return _c +} + +// RemoveFromPlacementGroup provides a mock function with given fields: ctx, server +func (_m *MockServerClient) RemoveFromPlacementGroup(ctx context.Context, server *hcloud.Server) (*hcloud.Action, *hcloud.Response, error) { + ret := _m.Called(ctx, server) + + if len(ret) == 0 { + panic("no return value specified for RemoveFromPlacementGroup") + } + + var r0 *hcloud.Action + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server) (*hcloud.Action, *hcloud.Response, error)); ok { + return rf(ctx, server) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server) *hcloud.Action); ok { + r0 = rf(ctx, server) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Action) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Server) *hcloud.Response); ok { + r1 = rf(ctx, server) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Server) error); ok { + r2 = rf(ctx, server) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_RemoveFromPlacementGroup_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveFromPlacementGroup' +type MockServerClient_RemoveFromPlacementGroup_Call struct { + *mock.Call +} + +// RemoveFromPlacementGroup is a helper method to define mock.On call +// - ctx context.Context +// - server *hcloud.Server +func (_e *MockServerClient_Expecter) RemoveFromPlacementGroup(ctx interface{}, server interface{}) *MockServerClient_RemoveFromPlacementGroup_Call { + return &MockServerClient_RemoveFromPlacementGroup_Call{Call: _e.mock.On("RemoveFromPlacementGroup", ctx, server)} +} + +func (_c *MockServerClient_RemoveFromPlacementGroup_Call) Run(run func(ctx context.Context, server *hcloud.Server)) *MockServerClient_RemoveFromPlacementGroup_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Server)) + }) + return _c +} + +func (_c *MockServerClient_RemoveFromPlacementGroup_Call) Return(_a0 *hcloud.Action, _a1 *hcloud.Response, _a2 error) *MockServerClient_RemoveFromPlacementGroup_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_RemoveFromPlacementGroup_Call) RunAndReturn(run func(context.Context, *hcloud.Server) (*hcloud.Action, *hcloud.Response, error)) *MockServerClient_RemoveFromPlacementGroup_Call { + _c.Call.Return(run) + return _c +} + +// RequestConsole provides a mock function with given fields: ctx, server +func (_m *MockServerClient) RequestConsole(ctx context.Context, server *hcloud.Server) (hcloud.ServerRequestConsoleResult, *hcloud.Response, error) { + ret := _m.Called(ctx, server) + + if len(ret) == 0 { + panic("no return value specified for RequestConsole") + } + + var r0 hcloud.ServerRequestConsoleResult + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server) (hcloud.ServerRequestConsoleResult, *hcloud.Response, error)); ok { + return rf(ctx, server) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server) hcloud.ServerRequestConsoleResult); ok { + r0 = rf(ctx, server) + } else { + r0 = ret.Get(0).(hcloud.ServerRequestConsoleResult) + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Server) *hcloud.Response); ok { + r1 = rf(ctx, server) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Server) error); ok { + r2 = rf(ctx, server) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_RequestConsole_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestConsole' +type MockServerClient_RequestConsole_Call struct { + *mock.Call +} + +// RequestConsole is a helper method to define mock.On call +// - ctx context.Context +// - server *hcloud.Server +func (_e *MockServerClient_Expecter) RequestConsole(ctx interface{}, server interface{}) *MockServerClient_RequestConsole_Call { + return &MockServerClient_RequestConsole_Call{Call: _e.mock.On("RequestConsole", ctx, server)} +} + +func (_c *MockServerClient_RequestConsole_Call) Run(run func(ctx context.Context, server *hcloud.Server)) *MockServerClient_RequestConsole_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Server)) + }) + return _c +} + +func (_c *MockServerClient_RequestConsole_Call) Return(_a0 hcloud.ServerRequestConsoleResult, _a1 *hcloud.Response, _a2 error) *MockServerClient_RequestConsole_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_RequestConsole_Call) RunAndReturn(run func(context.Context, *hcloud.Server) (hcloud.ServerRequestConsoleResult, *hcloud.Response, error)) *MockServerClient_RequestConsole_Call { + _c.Call.Return(run) + return _c +} + +// Reset provides a mock function with given fields: ctx, server +func (_m *MockServerClient) Reset(ctx context.Context, server *hcloud.Server) (*hcloud.Action, *hcloud.Response, error) { + ret := _m.Called(ctx, server) + + if len(ret) == 0 { + panic("no return value specified for Reset") + } + + var r0 *hcloud.Action + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server) (*hcloud.Action, *hcloud.Response, error)); ok { + return rf(ctx, server) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server) *hcloud.Action); ok { + r0 = rf(ctx, server) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Action) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Server) *hcloud.Response); ok { + r1 = rf(ctx, server) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Server) error); ok { + r2 = rf(ctx, server) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_Reset_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Reset' +type MockServerClient_Reset_Call struct { + *mock.Call +} + +// Reset is a helper method to define mock.On call +// - ctx context.Context +// - server *hcloud.Server +func (_e *MockServerClient_Expecter) Reset(ctx interface{}, server interface{}) *MockServerClient_Reset_Call { + return &MockServerClient_Reset_Call{Call: _e.mock.On("Reset", ctx, server)} +} + +func (_c *MockServerClient_Reset_Call) Run(run func(ctx context.Context, server *hcloud.Server)) *MockServerClient_Reset_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Server)) + }) + return _c +} + +func (_c *MockServerClient_Reset_Call) Return(_a0 *hcloud.Action, _a1 *hcloud.Response, _a2 error) *MockServerClient_Reset_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_Reset_Call) RunAndReturn(run func(context.Context, *hcloud.Server) (*hcloud.Action, *hcloud.Response, error)) *MockServerClient_Reset_Call { + _c.Call.Return(run) + return _c +} + +// ResetPassword provides a mock function with given fields: ctx, server +func (_m *MockServerClient) ResetPassword(ctx context.Context, server *hcloud.Server) (hcloud.ServerResetPasswordResult, *hcloud.Response, error) { + ret := _m.Called(ctx, server) + + if len(ret) == 0 { + panic("no return value specified for ResetPassword") + } + + var r0 hcloud.ServerResetPasswordResult + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server) (hcloud.ServerResetPasswordResult, *hcloud.Response, error)); ok { + return rf(ctx, server) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server) hcloud.ServerResetPasswordResult); ok { + r0 = rf(ctx, server) + } else { + r0 = ret.Get(0).(hcloud.ServerResetPasswordResult) + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Server) *hcloud.Response); ok { + r1 = rf(ctx, server) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Server) error); ok { + r2 = rf(ctx, server) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_ResetPassword_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ResetPassword' +type MockServerClient_ResetPassword_Call struct { + *mock.Call +} + +// ResetPassword is a helper method to define mock.On call +// - ctx context.Context +// - server *hcloud.Server +func (_e *MockServerClient_Expecter) ResetPassword(ctx interface{}, server interface{}) *MockServerClient_ResetPassword_Call { + return &MockServerClient_ResetPassword_Call{Call: _e.mock.On("ResetPassword", ctx, server)} +} + +func (_c *MockServerClient_ResetPassword_Call) Run(run func(ctx context.Context, server *hcloud.Server)) *MockServerClient_ResetPassword_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Server)) + }) + return _c +} + +func (_c *MockServerClient_ResetPassword_Call) Return(_a0 hcloud.ServerResetPasswordResult, _a1 *hcloud.Response, _a2 error) *MockServerClient_ResetPassword_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_ResetPassword_Call) RunAndReturn(run func(context.Context, *hcloud.Server) (hcloud.ServerResetPasswordResult, *hcloud.Response, error)) *MockServerClient_ResetPassword_Call { + _c.Call.Return(run) + return _c +} + +// Shutdown provides a mock function with given fields: ctx, server +func (_m *MockServerClient) Shutdown(ctx context.Context, server *hcloud.Server) (*hcloud.Action, *hcloud.Response, error) { + ret := _m.Called(ctx, server) + + if len(ret) == 0 { + panic("no return value specified for Shutdown") + } + + var r0 *hcloud.Action + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server) (*hcloud.Action, *hcloud.Response, error)); ok { + return rf(ctx, server) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server) *hcloud.Action); ok { + r0 = rf(ctx, server) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Action) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Server) *hcloud.Response); ok { + r1 = rf(ctx, server) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Server) error); ok { + r2 = rf(ctx, server) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_Shutdown_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Shutdown' +type MockServerClient_Shutdown_Call struct { + *mock.Call +} + +// Shutdown is a helper method to define mock.On call +// - ctx context.Context +// - server *hcloud.Server +func (_e *MockServerClient_Expecter) Shutdown(ctx interface{}, server interface{}) *MockServerClient_Shutdown_Call { + return &MockServerClient_Shutdown_Call{Call: _e.mock.On("Shutdown", ctx, server)} +} + +func (_c *MockServerClient_Shutdown_Call) Run(run func(ctx context.Context, server *hcloud.Server)) *MockServerClient_Shutdown_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Server)) + }) + return _c +} + +func (_c *MockServerClient_Shutdown_Call) Return(_a0 *hcloud.Action, _a1 *hcloud.Response, _a2 error) *MockServerClient_Shutdown_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_Shutdown_Call) RunAndReturn(run func(context.Context, *hcloud.Server) (*hcloud.Action, *hcloud.Response, error)) *MockServerClient_Shutdown_Call { + _c.Call.Return(run) + return _c +} + +// Update provides a mock function with given fields: ctx, server, opts +func (_m *MockServerClient) Update(ctx context.Context, server *hcloud.Server, opts hcloud.ServerUpdateOpts) (*hcloud.Server, *hcloud.Response, error) { + ret := _m.Called(ctx, server, opts) + + if len(ret) == 0 { + panic("no return value specified for Update") + } + + var r0 *hcloud.Server + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server, hcloud.ServerUpdateOpts) (*hcloud.Server, *hcloud.Response, error)); ok { + return rf(ctx, server, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, *hcloud.Server, hcloud.ServerUpdateOpts) *hcloud.Server); ok { + r0 = rf(ctx, server, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.Server) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *hcloud.Server, hcloud.ServerUpdateOpts) *hcloud.Response); ok { + r1 = rf(ctx, server, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, *hcloud.Server, hcloud.ServerUpdateOpts) error); ok { + r2 = rf(ctx, server, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerClient_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' +type MockServerClient_Update_Call struct { + *mock.Call +} + +// Update is a helper method to define mock.On call +// - ctx context.Context +// - server *hcloud.Server +// - opts hcloud.ServerUpdateOpts +func (_e *MockServerClient_Expecter) Update(ctx interface{}, server interface{}, opts interface{}) *MockServerClient_Update_Call { + return &MockServerClient_Update_Call{Call: _e.mock.On("Update", ctx, server, opts)} +} + +func (_c *MockServerClient_Update_Call) Run(run func(ctx context.Context, server *hcloud.Server, opts hcloud.ServerUpdateOpts)) *MockServerClient_Update_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*hcloud.Server), args[2].(hcloud.ServerUpdateOpts)) + }) + return _c +} + +func (_c *MockServerClient_Update_Call) Return(_a0 *hcloud.Server, _a1 *hcloud.Response, _a2 error) *MockServerClient_Update_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerClient_Update_Call) RunAndReturn(run func(context.Context, *hcloud.Server, hcloud.ServerUpdateOpts) (*hcloud.Server, *hcloud.Response, error)) *MockServerClient_Update_Call { + _c.Call.Return(run) + return _c +} + +// NewMockServerClient creates a new instance of MockServerClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockServerClient(t interface { + mock.TestingT + Cleanup(func()) +}) *MockServerClient { + mock := &MockServerClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/providers/hetznercloud/hcapi/mocks/mock_ServerTypeClient.go b/providers/hetznercloud/hcapi/mocks/mock_ServerTypeClient.go new file mode 100644 index 0000000..3a977e4 --- /dev/null +++ b/providers/hetznercloud/hcapi/mocks/mock_ServerTypeClient.go @@ -0,0 +1,427 @@ +// Code generated by mockery. DO NOT EDIT. + +package mocks + +import ( + context "context" + + hcloud "github.com/hetznercloud/hcloud-go/v2/hcloud" + + mock "github.com/stretchr/testify/mock" +) + +// MockServerTypeClient is an autogenerated mock type for the ServerTypeClient type +type MockServerTypeClient struct { + mock.Mock +} + +type MockServerTypeClient_Expecter struct { + mock *mock.Mock +} + +func (_m *MockServerTypeClient) EXPECT() *MockServerTypeClient_Expecter { + return &MockServerTypeClient_Expecter{mock: &_m.Mock} +} + +// All provides a mock function with given fields: ctx +func (_m *MockServerTypeClient) All(ctx context.Context) ([]*hcloud.ServerType, error) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for All") + } + + var r0 []*hcloud.ServerType + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) ([]*hcloud.ServerType, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) []*hcloud.ServerType); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*hcloud.ServerType) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockServerTypeClient_All_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'All' +type MockServerTypeClient_All_Call struct { + *mock.Call +} + +// All is a helper method to define mock.On call +// - ctx context.Context +func (_e *MockServerTypeClient_Expecter) All(ctx interface{}) *MockServerTypeClient_All_Call { + return &MockServerTypeClient_All_Call{Call: _e.mock.On("All", ctx)} +} + +func (_c *MockServerTypeClient_All_Call) Run(run func(ctx context.Context)) *MockServerTypeClient_All_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *MockServerTypeClient_All_Call) Return(_a0 []*hcloud.ServerType, _a1 error) *MockServerTypeClient_All_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockServerTypeClient_All_Call) RunAndReturn(run func(context.Context) ([]*hcloud.ServerType, error)) *MockServerTypeClient_All_Call { + _c.Call.Return(run) + return _c +} + +// AllWithOpts provides a mock function with given fields: ctx, opts +func (_m *MockServerTypeClient) AllWithOpts(ctx context.Context, opts hcloud.ServerTypeListOpts) ([]*hcloud.ServerType, error) { + ret := _m.Called(ctx, opts) + + if len(ret) == 0 { + panic("no return value specified for AllWithOpts") + } + + var r0 []*hcloud.ServerType + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, hcloud.ServerTypeListOpts) ([]*hcloud.ServerType, error)); ok { + return rf(ctx, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, hcloud.ServerTypeListOpts) []*hcloud.ServerType); ok { + r0 = rf(ctx, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*hcloud.ServerType) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, hcloud.ServerTypeListOpts) error); ok { + r1 = rf(ctx, opts) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockServerTypeClient_AllWithOpts_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AllWithOpts' +type MockServerTypeClient_AllWithOpts_Call struct { + *mock.Call +} + +// AllWithOpts is a helper method to define mock.On call +// - ctx context.Context +// - opts hcloud.ServerTypeListOpts +func (_e *MockServerTypeClient_Expecter) AllWithOpts(ctx interface{}, opts interface{}) *MockServerTypeClient_AllWithOpts_Call { + return &MockServerTypeClient_AllWithOpts_Call{Call: _e.mock.On("AllWithOpts", ctx, opts)} +} + +func (_c *MockServerTypeClient_AllWithOpts_Call) Run(run func(ctx context.Context, opts hcloud.ServerTypeListOpts)) *MockServerTypeClient_AllWithOpts_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(hcloud.ServerTypeListOpts)) + }) + return _c +} + +func (_c *MockServerTypeClient_AllWithOpts_Call) Return(_a0 []*hcloud.ServerType, _a1 error) *MockServerTypeClient_AllWithOpts_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockServerTypeClient_AllWithOpts_Call) RunAndReturn(run func(context.Context, hcloud.ServerTypeListOpts) ([]*hcloud.ServerType, error)) *MockServerTypeClient_AllWithOpts_Call { + _c.Call.Return(run) + return _c +} + +// Get provides a mock function with given fields: ctx, idOrName +func (_m *MockServerTypeClient) Get(ctx context.Context, idOrName string) (*hcloud.ServerType, *hcloud.Response, error) { + ret := _m.Called(ctx, idOrName) + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 *hcloud.ServerType + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*hcloud.ServerType, *hcloud.Response, error)); ok { + return rf(ctx, idOrName) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *hcloud.ServerType); ok { + r0 = rf(ctx, idOrName) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.ServerType) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) *hcloud.Response); ok { + r1 = rf(ctx, idOrName) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, string) error); ok { + r2 = rf(ctx, idOrName) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerTypeClient_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type MockServerTypeClient_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +// - ctx context.Context +// - idOrName string +func (_e *MockServerTypeClient_Expecter) Get(ctx interface{}, idOrName interface{}) *MockServerTypeClient_Get_Call { + return &MockServerTypeClient_Get_Call{Call: _e.mock.On("Get", ctx, idOrName)} +} + +func (_c *MockServerTypeClient_Get_Call) Run(run func(ctx context.Context, idOrName string)) *MockServerTypeClient_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockServerTypeClient_Get_Call) Return(_a0 *hcloud.ServerType, _a1 *hcloud.Response, _a2 error) *MockServerTypeClient_Get_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerTypeClient_Get_Call) RunAndReturn(run func(context.Context, string) (*hcloud.ServerType, *hcloud.Response, error)) *MockServerTypeClient_Get_Call { + _c.Call.Return(run) + return _c +} + +// GetByID provides a mock function with given fields: ctx, id +func (_m *MockServerTypeClient) GetByID(ctx context.Context, id int64) (*hcloud.ServerType, *hcloud.Response, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for GetByID") + } + + var r0 *hcloud.ServerType + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, int64) (*hcloud.ServerType, *hcloud.Response, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, int64) *hcloud.ServerType); ok { + r0 = rf(ctx, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.ServerType) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, int64) *hcloud.Response); ok { + r1 = rf(ctx, id) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, int64) error); ok { + r2 = rf(ctx, id) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerTypeClient_GetByID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByID' +type MockServerTypeClient_GetByID_Call struct { + *mock.Call +} + +// GetByID is a helper method to define mock.On call +// - ctx context.Context +// - id int64 +func (_e *MockServerTypeClient_Expecter) GetByID(ctx interface{}, id interface{}) *MockServerTypeClient_GetByID_Call { + return &MockServerTypeClient_GetByID_Call{Call: _e.mock.On("GetByID", ctx, id)} +} + +func (_c *MockServerTypeClient_GetByID_Call) Run(run func(ctx context.Context, id int64)) *MockServerTypeClient_GetByID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(int64)) + }) + return _c +} + +func (_c *MockServerTypeClient_GetByID_Call) Return(_a0 *hcloud.ServerType, _a1 *hcloud.Response, _a2 error) *MockServerTypeClient_GetByID_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerTypeClient_GetByID_Call) RunAndReturn(run func(context.Context, int64) (*hcloud.ServerType, *hcloud.Response, error)) *MockServerTypeClient_GetByID_Call { + _c.Call.Return(run) + return _c +} + +// GetByName provides a mock function with given fields: ctx, name +func (_m *MockServerTypeClient) GetByName(ctx context.Context, name string) (*hcloud.ServerType, *hcloud.Response, error) { + ret := _m.Called(ctx, name) + + if len(ret) == 0 { + panic("no return value specified for GetByName") + } + + var r0 *hcloud.ServerType + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*hcloud.ServerType, *hcloud.Response, error)); ok { + return rf(ctx, name) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *hcloud.ServerType); ok { + r0 = rf(ctx, name) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*hcloud.ServerType) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) *hcloud.Response); ok { + r1 = rf(ctx, name) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, string) error); ok { + r2 = rf(ctx, name) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerTypeClient_GetByName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByName' +type MockServerTypeClient_GetByName_Call struct { + *mock.Call +} + +// GetByName is a helper method to define mock.On call +// - ctx context.Context +// - name string +func (_e *MockServerTypeClient_Expecter) GetByName(ctx interface{}, name interface{}) *MockServerTypeClient_GetByName_Call { + return &MockServerTypeClient_GetByName_Call{Call: _e.mock.On("GetByName", ctx, name)} +} + +func (_c *MockServerTypeClient_GetByName_Call) Run(run func(ctx context.Context, name string)) *MockServerTypeClient_GetByName_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockServerTypeClient_GetByName_Call) Return(_a0 *hcloud.ServerType, _a1 *hcloud.Response, _a2 error) *MockServerTypeClient_GetByName_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerTypeClient_GetByName_Call) RunAndReturn(run func(context.Context, string) (*hcloud.ServerType, *hcloud.Response, error)) *MockServerTypeClient_GetByName_Call { + _c.Call.Return(run) + return _c +} + +// List provides a mock function with given fields: ctx, opts +func (_m *MockServerTypeClient) List(ctx context.Context, opts hcloud.ServerTypeListOpts) ([]*hcloud.ServerType, *hcloud.Response, error) { + ret := _m.Called(ctx, opts) + + if len(ret) == 0 { + panic("no return value specified for List") + } + + var r0 []*hcloud.ServerType + var r1 *hcloud.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, hcloud.ServerTypeListOpts) ([]*hcloud.ServerType, *hcloud.Response, error)); ok { + return rf(ctx, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, hcloud.ServerTypeListOpts) []*hcloud.ServerType); ok { + r0 = rf(ctx, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*hcloud.ServerType) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, hcloud.ServerTypeListOpts) *hcloud.Response); ok { + r1 = rf(ctx, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*hcloud.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, hcloud.ServerTypeListOpts) error); ok { + r2 = rf(ctx, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockServerTypeClient_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' +type MockServerTypeClient_List_Call struct { + *mock.Call +} + +// List is a helper method to define mock.On call +// - ctx context.Context +// - opts hcloud.ServerTypeListOpts +func (_e *MockServerTypeClient_Expecter) List(ctx interface{}, opts interface{}) *MockServerTypeClient_List_Call { + return &MockServerTypeClient_List_Call{Call: _e.mock.On("List", ctx, opts)} +} + +func (_c *MockServerTypeClient_List_Call) Run(run func(ctx context.Context, opts hcloud.ServerTypeListOpts)) *MockServerTypeClient_List_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(hcloud.ServerTypeListOpts)) + }) + return _c +} + +func (_c *MockServerTypeClient_List_Call) Return(_a0 []*hcloud.ServerType, _a1 *hcloud.Response, _a2 error) *MockServerTypeClient_List_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockServerTypeClient_List_Call) RunAndReturn(run func(context.Context, hcloud.ServerTypeListOpts) ([]*hcloud.ServerType, *hcloud.Response, error)) *MockServerTypeClient_List_Call { + _c.Call.Return(run) + return _c +} + +// NewMockServerTypeClient creates a new instance of MockServerTypeClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockServerTypeClient(t interface { + mock.TestingT + Cleanup(func()) +}) *MockServerTypeClient { + mock := &MockServerTypeClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/providers/hetznercloud/provider.go b/providers/hetznercloud/provider.go index 14927ac..850c03f 100644 --- a/providers/hetznercloud/provider.go +++ b/providers/hetznercloud/provider.go @@ -13,6 +13,7 @@ import ( "go.woodpecker-ci.org/autoscaler/config" "go.woodpecker-ci.org/autoscaler/engine" + "go.woodpecker-ci.org/autoscaler/providers/hetznercloud/hcapi" "go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker" ) @@ -22,6 +23,7 @@ var ( ErrSSHKeyNotFound = errors.New("SSH key not found") ErrNetworkNotFound = errors.New("network not found") ErrFirewallNotFound = errors.New("firewall not found") + ErrServerTypeNotFound = errors.New("server type not found") ) type Provider struct { @@ -37,7 +39,7 @@ type Provider struct { firewalls []string enableIPv4 bool enableIPv6 bool - client *hcloud.Client + client hcapi.Client } func New(c *cli.Context, config *config.Config) (engine.Provider, error) { @@ -54,7 +56,7 @@ func New(c *cli.Context, config *config.Config) (engine.Provider, error) { config: config, } - d.client = hcloud.NewClient(hcloud.WithToken(c.String("hetznercloud-api-token"))) + d.client = hcapi.NewClient(hcloud.WithToken(c.String("hetznercloud-api-token"))) userDataStr := engine.CloudInitUserDataUbuntuDefault if _userDataStr := c.String("hetznercloud-user-data"); _userDataStr != "" { @@ -91,12 +93,15 @@ func (d *Provider) DeployAgent(ctx context.Context, agent *woodpecker.Agent) err return fmt.Errorf("%s: RenderUserDataTemplate: %w", d.name, err) } - serverType, _, err := d.client.ServerType.GetByName(ctx, d.serverType) + serverType, _, err := d.client.ServerType().GetByName(ctx, d.serverType) if err != nil { return fmt.Errorf("%s: ServerType.GetByName: %w", d.name, err) } + if serverType == nil { + return fmt.Errorf("%s: %w: %s", d.name, ErrServerTypeNotFound, d.serverType) + } - image, _, err := d.client.Image.GetByNameAndArchitecture(ctx, d.image, serverType.Architecture) + image, _, err := d.client.Image().GetByNameAndArchitecture(ctx, d.image, serverType.Architecture) if err != nil { return fmt.Errorf("%s: Image.GetByNameAndArchitecture: %w", d.name, err) } @@ -106,7 +111,7 @@ func (d *Provider) DeployAgent(ctx context.Context, agent *woodpecker.Agent) err sshKeys := make([]*hcloud.SSHKey, 0) for _, item := range d.sshKeys { - key, _, err := d.client.SSHKey.GetByName(ctx, item) + key, _, err := d.client.SSHKey().GetByName(ctx, item) if err != nil { return fmt.Errorf("%s: SSHKey.GetByName: %w", d.name, err) } @@ -118,7 +123,7 @@ func (d *Provider) DeployAgent(ctx context.Context, agent *woodpecker.Agent) err networks := make([]*hcloud.Network, 0) for _, item := range d.networks { - network, _, err := d.client.Network.GetByName(ctx, item) + network, _, err := d.client.Network().GetByName(ctx, item) if err != nil { return fmt.Errorf("%s: Network.GetByName: %w", d.name, err) } @@ -130,7 +135,7 @@ func (d *Provider) DeployAgent(ctx context.Context, agent *woodpecker.Agent) err firewalls := make([]*hcloud.ServerCreateFirewall, 0) for _, item := range d.firewalls { - fw, _, err := d.client.Firewall.GetByName(ctx, item) + fw, _, err := d.client.Firewall().GetByName(ctx, item) if err != nil { return fmt.Errorf("%s: Firewall.GetByName: %w", d.name, err) } @@ -140,7 +145,7 @@ func (d *Provider) DeployAgent(ctx context.Context, agent *woodpecker.Agent) err firewalls = append(firewalls, &hcloud.ServerCreateFirewall{Firewall: hcloud.Firewall{ID: fw.ID}}) } - _, _, err = d.client.Server.Create(ctx, hcloud.ServerCreateOpts{ + _, _, err = d.client.Server().Create(ctx, hcloud.ServerCreateOpts{ Name: agent.Name, UserData: userdataString, Image: image, @@ -165,7 +170,7 @@ func (d *Provider) DeployAgent(ctx context.Context, agent *woodpecker.Agent) err } func (d *Provider) getAgent(ctx context.Context, agent *woodpecker.Agent) (*hcloud.Server, error) { - server, _, err := d.client.Server.GetByName(ctx, agent.Name) + server, _, err := d.client.Server().GetByName(ctx, agent.Name) if err != nil { return nil, fmt.Errorf("%s: Server.GetByName %w", d.name, err) } @@ -183,7 +188,7 @@ func (d *Provider) RemoveAgent(ctx context.Context, agent *woodpecker.Agent) err return nil } - _, _, err = d.client.Server.DeleteWithResult(ctx, server) + _, _, err = d.client.Server().DeleteWithResult(ctx, server) if err != nil { return fmt.Errorf("%s: Server.DeleteWithResults %w", d.name, err) } @@ -194,7 +199,7 @@ func (d *Provider) RemoveAgent(ctx context.Context, agent *woodpecker.Agent) err func (d *Provider) ListDeployedAgentNames(ctx context.Context) ([]string, error) { var names []string - servers, err := d.client.Server.AllWithOpts(ctx, + servers, err := d.client.Server().AllWithOpts(ctx, hcloud.ServerListOpts{ ListOpts: hcloud.ListOpts{LabelSelector: fmt.Sprintf("%s==%s", engine.LabelPool, d.config.PoolID)}, }) diff --git a/providers/hetznercloud/provider_test.go b/providers/hetznercloud/provider_test.go new file mode 100644 index 0000000..bc3a419 --- /dev/null +++ b/providers/hetznercloud/provider_test.go @@ -0,0 +1,78 @@ +package hetznercloud + +import ( + "context" + "testing" + "text/template" + + "github.com/hetznercloud/hcloud-go/v2/hcloud" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" + + "go.woodpecker-ci.org/autoscaler/config" + "go.woodpecker-ci.org/autoscaler/providers/hetznercloud/hcapi/mocks" + "go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker" +) + +func TestDeployAgent(t *testing.T) { + tests := []struct { + name string + setupMocks func(*mocks.MockClient) + userdata string + sshkeys []string + expectedError string + }{ + { + name: "InvalidUserData", + setupMocks: func(_ *mocks.MockClient) {}, + userdata: "{{.InvalidField}}", + expectedError: "RenderUserDataTemplate", + }, + { + name: "ServerTypeNotFound", + setupMocks: func(mockClient *mocks.MockClient) { + mockServerTypeClient := mocks.NewMockServerTypeClient(t) + mockServerTypeClient.On("GetByName", mock.Anything, mock.Anything).Return(nil, nil, nil) + mockClient.On("ServerType").Return(mockServerTypeClient) + }, + expectedError: ErrServerTypeNotFound.Error(), + }, + { + name: "ImageNotFound", + setupMocks: func(mockClient *mocks.MockClient) { + mockServerType := &hcloud.ServerType{Architecture: "amd64"} + mockServerTypeClient := mocks.NewMockServerTypeClient(t) + mockServerTypeClient.On("GetByName", mock.Anything, mock.Anything).Return(mockServerType, nil, nil) + mockClient.On("ServerType").Return(mockServerTypeClient) + + mockImageClient := mocks.NewMockImageClient(t) + mockImageClient.On("GetByNameAndArchitecture", mock.Anything, mock.Anything, mock.Anything).Return(nil, nil, nil) + mockClient.On("Image").Return(mockImageClient) + }, + expectedError: ErrImageNotFound.Error(), + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + mockClient := mocks.NewMockClient(t) + tt.setupMocks(mockClient) + + provider := &Provider{ + client: mockClient, + config: &config.Config{}, + userData: template.Must(template.New("").Parse(tt.userdata)), + sshKeys: tt.sshkeys, + } + + agent := &woodpecker.Agent{} + err := provider.DeployAgent(context.Background(), agent) + if tt.expectedError != "" { + assert.Error(t, err) + assert.Contains(t, err.Error(), tt.expectedError) + } else { + assert.NoError(t, err) + } + }) + } +}