consul/agent/hcp/mock_TelemetryProvider.go
Melissa Kam b0e87dbe13
[CC-7049] Stop the HCP manager when link is deleted (#20351)
* Add Stop method to telemetry provider

Stop the main loop of the provider and set the config
to disabled.

* Add interface for telemetry provider

Added for easier testing. Also renamed Run to Start, which better
fits with Stop.

* Add Stop method to HCP manager

* Add manager interface, rename implementation

Add interface for easier testing, rename existing Manager to HCPManager.

* Stop HCP manager in link Finalizer

* Attempt to cleanup if resource has been deleted

The link should be cleaned up by the finalizer, but there's an edge
case in a multi-server setup where the link is fully deleted on one
server before the other server reconciles. This will cover the case
where the reconcile happens after the resource is deleted.

* Add a delete mananagement token function

Passes a function to the HCP manager that deletes the management token
that was initially created by the manager.

* Delete token as part of stopping the manager

* Lock around disabling config, remove descriptions
2024-01-30 09:40:36 -06:00

116 lines
3.2 KiB
Go

// Code generated by mockery v2.38.0. DO NOT EDIT.
package hcp
import (
context "context"
mock "github.com/stretchr/testify/mock"
)
// MockTelemetryProvider is an autogenerated mock type for the TelemetryProvider type
type MockTelemetryProvider struct {
mock.Mock
}
type MockTelemetryProvider_Expecter struct {
mock *mock.Mock
}
func (_m *MockTelemetryProvider) EXPECT() *MockTelemetryProvider_Expecter {
return &MockTelemetryProvider_Expecter{mock: &_m.Mock}
}
// Start provides a mock function with given fields: ctx, c
func (_m *MockTelemetryProvider) Start(ctx context.Context, c *HCPProviderCfg) error {
ret := _m.Called(ctx, c)
if len(ret) == 0 {
panic("no return value specified for Start")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, *HCPProviderCfg) error); ok {
r0 = rf(ctx, c)
} else {
r0 = ret.Error(0)
}
return r0
}
// MockTelemetryProvider_Start_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Start'
type MockTelemetryProvider_Start_Call struct {
*mock.Call
}
// Start is a helper method to define mock.On call
// - ctx context.Context
// - c *HCPProviderCfg
func (_e *MockTelemetryProvider_Expecter) Start(ctx interface{}, c interface{}) *MockTelemetryProvider_Start_Call {
return &MockTelemetryProvider_Start_Call{Call: _e.mock.On("Start", ctx, c)}
}
func (_c *MockTelemetryProvider_Start_Call) Run(run func(ctx context.Context, c *HCPProviderCfg)) *MockTelemetryProvider_Start_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(*HCPProviderCfg))
})
return _c
}
func (_c *MockTelemetryProvider_Start_Call) Return(_a0 error) *MockTelemetryProvider_Start_Call {
_c.Call.Return(_a0)
return _c
}
func (_c *MockTelemetryProvider_Start_Call) RunAndReturn(run func(context.Context, *HCPProviderCfg) error) *MockTelemetryProvider_Start_Call {
_c.Call.Return(run)
return _c
}
// Stop provides a mock function with given fields:
func (_m *MockTelemetryProvider) Stop() {
_m.Called()
}
// MockTelemetryProvider_Stop_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Stop'
type MockTelemetryProvider_Stop_Call struct {
*mock.Call
}
// Stop is a helper method to define mock.On call
func (_e *MockTelemetryProvider_Expecter) Stop() *MockTelemetryProvider_Stop_Call {
return &MockTelemetryProvider_Stop_Call{Call: _e.mock.On("Stop")}
}
func (_c *MockTelemetryProvider_Stop_Call) Run(run func()) *MockTelemetryProvider_Stop_Call {
_c.Call.Run(func(args mock.Arguments) {
run()
})
return _c
}
func (_c *MockTelemetryProvider_Stop_Call) Return() *MockTelemetryProvider_Stop_Call {
_c.Call.Return()
return _c
}
func (_c *MockTelemetryProvider_Stop_Call) RunAndReturn(run func()) *MockTelemetryProvider_Stop_Call {
_c.Call.Return(run)
return _c
}
// NewMockTelemetryProvider creates a new instance of MockTelemetryProvider. 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 NewMockTelemetryProvider(t interface {
mock.TestingT
Cleanup(func())
}) *MockTelemetryProvider {
mock := &MockTelemetryProvider{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
}