joshuar-go-hass-agent/internal/agent/agent_mocks_test.go

628 lines
18 KiB
Go

// Code generated by moq; DO NOT EDIT.
// github.com/matryer/moq
package agent
import (
"context"
fyneui "github.com/joshuar/go-hass-agent/internal/agent/ui/fyneUI"
"github.com/joshuar/go-hass-agent/internal/hass/sensor"
"github.com/joshuar/go-hass-agent/internal/preferences"
mqttapi "github.com/joshuar/go-hass-anything/v11/pkg/mqtt"
"sync"
)
// Ensure, that uiMock does implement ui.
// If this is not the case, regenerate this file with moq.
var _ ui = &uiMock{}
// uiMock is a mock implementation of ui.
//
// func TestSomethingThatUsesui(t *testing.T) {
//
// // make and configure a mocked ui
// mockedui := &uiMock{
// DisplayNotificationFunc: func(n fyneui.Notification) {
// panic("mock out the DisplayNotification method")
// },
// DisplayRegistrationWindowFunc: func(ctx context.Context, prefs *preferences.Registration) chan bool {
// panic("mock out the DisplayRegistrationWindow method")
// },
// DisplayTrayIconFunc: func(ctx context.Context, cancelFunc context.CancelFunc) {
// panic("mock out the DisplayTrayIcon method")
// },
// RunFunc: func(ctx context.Context) {
// panic("mock out the Run method")
// },
// }
//
// // use mockedui in code that requires ui
// // and then make assertions.
//
// }
type uiMock struct {
// DisplayNotificationFunc mocks the DisplayNotification method.
DisplayNotificationFunc func(n fyneui.Notification)
// DisplayRegistrationWindowFunc mocks the DisplayRegistrationWindow method.
DisplayRegistrationWindowFunc func(ctx context.Context, prefs *preferences.Registration) chan bool
// DisplayTrayIconFunc mocks the DisplayTrayIcon method.
DisplayTrayIconFunc func(ctx context.Context, cancelFunc context.CancelFunc)
// RunFunc mocks the Run method.
RunFunc func(ctx context.Context)
// calls tracks calls to the methods.
calls struct {
// DisplayNotification holds details about calls to the DisplayNotification method.
DisplayNotification []struct {
// N is the n argument value.
N fyneui.Notification
}
// DisplayRegistrationWindow holds details about calls to the DisplayRegistrationWindow method.
DisplayRegistrationWindow []struct {
// Ctx is the ctx argument value.
Ctx context.Context
// Prefs is the prefs argument value.
Prefs *preferences.Registration
}
// DisplayTrayIcon holds details about calls to the DisplayTrayIcon method.
DisplayTrayIcon []struct {
// Ctx is the ctx argument value.
Ctx context.Context
// CancelFunc is the cancelFunc argument value.
CancelFunc context.CancelFunc
}
// Run holds details about calls to the Run method.
Run []struct {
// Ctx is the ctx argument value.
Ctx context.Context
}
}
lockDisplayNotification sync.RWMutex
lockDisplayRegistrationWindow sync.RWMutex
lockDisplayTrayIcon sync.RWMutex
lockRun sync.RWMutex
}
// DisplayNotification calls DisplayNotificationFunc.
func (mock *uiMock) DisplayNotification(n fyneui.Notification) {
if mock.DisplayNotificationFunc == nil {
panic("uiMock.DisplayNotificationFunc: method is nil but ui.DisplayNotification was just called")
}
callInfo := struct {
N fyneui.Notification
}{
N: n,
}
mock.lockDisplayNotification.Lock()
mock.calls.DisplayNotification = append(mock.calls.DisplayNotification, callInfo)
mock.lockDisplayNotification.Unlock()
mock.DisplayNotificationFunc(n)
}
// DisplayNotificationCalls gets all the calls that were made to DisplayNotification.
// Check the length with:
//
// len(mockedui.DisplayNotificationCalls())
func (mock *uiMock) DisplayNotificationCalls() []struct {
N fyneui.Notification
} {
var calls []struct {
N fyneui.Notification
}
mock.lockDisplayNotification.RLock()
calls = mock.calls.DisplayNotification
mock.lockDisplayNotification.RUnlock()
return calls
}
// DisplayRegistrationWindow calls DisplayRegistrationWindowFunc.
func (mock *uiMock) DisplayRegistrationWindow(ctx context.Context, prefs *preferences.Registration) chan bool {
if mock.DisplayRegistrationWindowFunc == nil {
panic("uiMock.DisplayRegistrationWindowFunc: method is nil but ui.DisplayRegistrationWindow was just called")
}
callInfo := struct {
Ctx context.Context
Prefs *preferences.Registration
}{
Ctx: ctx,
Prefs: prefs,
}
mock.lockDisplayRegistrationWindow.Lock()
mock.calls.DisplayRegistrationWindow = append(mock.calls.DisplayRegistrationWindow, callInfo)
mock.lockDisplayRegistrationWindow.Unlock()
return mock.DisplayRegistrationWindowFunc(ctx, prefs)
}
// DisplayRegistrationWindowCalls gets all the calls that were made to DisplayRegistrationWindow.
// Check the length with:
//
// len(mockedui.DisplayRegistrationWindowCalls())
func (mock *uiMock) DisplayRegistrationWindowCalls() []struct {
Ctx context.Context
Prefs *preferences.Registration
} {
var calls []struct {
Ctx context.Context
Prefs *preferences.Registration
}
mock.lockDisplayRegistrationWindow.RLock()
calls = mock.calls.DisplayRegistrationWindow
mock.lockDisplayRegistrationWindow.RUnlock()
return calls
}
// DisplayTrayIcon calls DisplayTrayIconFunc.
func (mock *uiMock) DisplayTrayIcon(ctx context.Context, cancelFunc context.CancelFunc) {
if mock.DisplayTrayIconFunc == nil {
panic("uiMock.DisplayTrayIconFunc: method is nil but ui.DisplayTrayIcon was just called")
}
callInfo := struct {
Ctx context.Context
CancelFunc context.CancelFunc
}{
Ctx: ctx,
CancelFunc: cancelFunc,
}
mock.lockDisplayTrayIcon.Lock()
mock.calls.DisplayTrayIcon = append(mock.calls.DisplayTrayIcon, callInfo)
mock.lockDisplayTrayIcon.Unlock()
mock.DisplayTrayIconFunc(ctx, cancelFunc)
}
// DisplayTrayIconCalls gets all the calls that were made to DisplayTrayIcon.
// Check the length with:
//
// len(mockedui.DisplayTrayIconCalls())
func (mock *uiMock) DisplayTrayIconCalls() []struct {
Ctx context.Context
CancelFunc context.CancelFunc
} {
var calls []struct {
Ctx context.Context
CancelFunc context.CancelFunc
}
mock.lockDisplayTrayIcon.RLock()
calls = mock.calls.DisplayTrayIcon
mock.lockDisplayTrayIcon.RUnlock()
return calls
}
// Run calls RunFunc.
func (mock *uiMock) Run(ctx context.Context) {
if mock.RunFunc == nil {
panic("uiMock.RunFunc: method is nil but ui.Run was just called")
}
callInfo := struct {
Ctx context.Context
}{
Ctx: ctx,
}
mock.lockRun.Lock()
mock.calls.Run = append(mock.calls.Run, callInfo)
mock.lockRun.Unlock()
mock.RunFunc(ctx)
}
// RunCalls gets all the calls that were made to Run.
// Check the length with:
//
// len(mockedui.RunCalls())
func (mock *uiMock) RunCalls() []struct {
Ctx context.Context
} {
var calls []struct {
Ctx context.Context
}
mock.lockRun.RLock()
calls = mock.calls.Run
mock.lockRun.RUnlock()
return calls
}
// Ensure, that SensorControllerMock does implement SensorController.
// If this is not the case, regenerate this file with moq.
var _ SensorController = &SensorControllerMock{}
// SensorControllerMock is a mock implementation of SensorController.
//
// func TestSomethingThatUsesSensorController(t *testing.T) {
//
// // make and configure a mocked SensorController
// mockedSensorController := &SensorControllerMock{
// ActiveWorkersFunc: func() []string {
// panic("mock out the ActiveWorkers method")
// },
// IDFunc: func() string {
// panic("mock out the ID method")
// },
// InactiveWorkersFunc: func() []string {
// panic("mock out the InactiveWorkers method")
// },
// StartFunc: func(ctx context.Context, name string) (<-chan sensor.Details, error) {
// panic("mock out the Start method")
// },
// StatesFunc: func(ctx context.Context) []sensor.Details {
// panic("mock out the States method")
// },
// StopFunc: func(name string) error {
// panic("mock out the Stop method")
// },
// }
//
// // use mockedSensorController in code that requires SensorController
// // and then make assertions.
//
// }
type SensorControllerMock struct {
// ActiveWorkersFunc mocks the ActiveWorkers method.
ActiveWorkersFunc func() []string
// IDFunc mocks the ID method.
IDFunc func() string
// InactiveWorkersFunc mocks the InactiveWorkers method.
InactiveWorkersFunc func() []string
// StartFunc mocks the Start method.
StartFunc func(ctx context.Context, name string) (<-chan sensor.Details, error)
// StatesFunc mocks the States method.
StatesFunc func(ctx context.Context) []sensor.Details
// StopFunc mocks the Stop method.
StopFunc func(name string) error
// calls tracks calls to the methods.
calls struct {
// ActiveWorkers holds details about calls to the ActiveWorkers method.
ActiveWorkers []struct {
}
// ID holds details about calls to the ID method.
ID []struct {
}
// InactiveWorkers holds details about calls to the InactiveWorkers method.
InactiveWorkers []struct {
}
// Start holds details about calls to the Start method.
Start []struct {
// Ctx is the ctx argument value.
Ctx context.Context
// Name is the name argument value.
Name string
}
// States holds details about calls to the States method.
States []struct {
// Ctx is the ctx argument value.
Ctx context.Context
}
// Stop holds details about calls to the Stop method.
Stop []struct {
// Name is the name argument value.
Name string
}
}
lockActiveWorkers sync.RWMutex
lockID sync.RWMutex
lockInactiveWorkers sync.RWMutex
lockStart sync.RWMutex
lockStates sync.RWMutex
lockStop sync.RWMutex
}
// ActiveWorkers calls ActiveWorkersFunc.
func (mock *SensorControllerMock) ActiveWorkers() []string {
if mock.ActiveWorkersFunc == nil {
panic("SensorControllerMock.ActiveWorkersFunc: method is nil but SensorController.ActiveWorkers was just called")
}
callInfo := struct {
}{}
mock.lockActiveWorkers.Lock()
mock.calls.ActiveWorkers = append(mock.calls.ActiveWorkers, callInfo)
mock.lockActiveWorkers.Unlock()
return mock.ActiveWorkersFunc()
}
// ActiveWorkersCalls gets all the calls that were made to ActiveWorkers.
// Check the length with:
//
// len(mockedSensorController.ActiveWorkersCalls())
func (mock *SensorControllerMock) ActiveWorkersCalls() []struct {
} {
var calls []struct {
}
mock.lockActiveWorkers.RLock()
calls = mock.calls.ActiveWorkers
mock.lockActiveWorkers.RUnlock()
return calls
}
// ID calls IDFunc.
func (mock *SensorControllerMock) ID() string {
if mock.IDFunc == nil {
panic("SensorControllerMock.IDFunc: method is nil but SensorController.ID was just called")
}
callInfo := struct {
}{}
mock.lockID.Lock()
mock.calls.ID = append(mock.calls.ID, callInfo)
mock.lockID.Unlock()
return mock.IDFunc()
}
// IDCalls gets all the calls that were made to ID.
// Check the length with:
//
// len(mockedSensorController.IDCalls())
func (mock *SensorControllerMock) IDCalls() []struct {
} {
var calls []struct {
}
mock.lockID.RLock()
calls = mock.calls.ID
mock.lockID.RUnlock()
return calls
}
// InactiveWorkers calls InactiveWorkersFunc.
func (mock *SensorControllerMock) InactiveWorkers() []string {
if mock.InactiveWorkersFunc == nil {
panic("SensorControllerMock.InactiveWorkersFunc: method is nil but SensorController.InactiveWorkers was just called")
}
callInfo := struct {
}{}
mock.lockInactiveWorkers.Lock()
mock.calls.InactiveWorkers = append(mock.calls.InactiveWorkers, callInfo)
mock.lockInactiveWorkers.Unlock()
return mock.InactiveWorkersFunc()
}
// InactiveWorkersCalls gets all the calls that were made to InactiveWorkers.
// Check the length with:
//
// len(mockedSensorController.InactiveWorkersCalls())
func (mock *SensorControllerMock) InactiveWorkersCalls() []struct {
} {
var calls []struct {
}
mock.lockInactiveWorkers.RLock()
calls = mock.calls.InactiveWorkers
mock.lockInactiveWorkers.RUnlock()
return calls
}
// Start calls StartFunc.
func (mock *SensorControllerMock) Start(ctx context.Context, name string) (<-chan sensor.Details, error) {
if mock.StartFunc == nil {
panic("SensorControllerMock.StartFunc: method is nil but SensorController.Start was just called")
}
callInfo := struct {
Ctx context.Context
Name string
}{
Ctx: ctx,
Name: name,
}
mock.lockStart.Lock()
mock.calls.Start = append(mock.calls.Start, callInfo)
mock.lockStart.Unlock()
return mock.StartFunc(ctx, name)
}
// StartCalls gets all the calls that were made to Start.
// Check the length with:
//
// len(mockedSensorController.StartCalls())
func (mock *SensorControllerMock) StartCalls() []struct {
Ctx context.Context
Name string
} {
var calls []struct {
Ctx context.Context
Name string
}
mock.lockStart.RLock()
calls = mock.calls.Start
mock.lockStart.RUnlock()
return calls
}
// States calls StatesFunc.
func (mock *SensorControllerMock) States(ctx context.Context) []sensor.Details {
if mock.StatesFunc == nil {
panic("SensorControllerMock.StatesFunc: method is nil but SensorController.States was just called")
}
callInfo := struct {
Ctx context.Context
}{
Ctx: ctx,
}
mock.lockStates.Lock()
mock.calls.States = append(mock.calls.States, callInfo)
mock.lockStates.Unlock()
return mock.StatesFunc(ctx)
}
// StatesCalls gets all the calls that were made to States.
// Check the length with:
//
// len(mockedSensorController.StatesCalls())
func (mock *SensorControllerMock) StatesCalls() []struct {
Ctx context.Context
} {
var calls []struct {
Ctx context.Context
}
mock.lockStates.RLock()
calls = mock.calls.States
mock.lockStates.RUnlock()
return calls
}
// Stop calls StopFunc.
func (mock *SensorControllerMock) Stop(name string) error {
if mock.StopFunc == nil {
panic("SensorControllerMock.StopFunc: method is nil but SensorController.Stop was just called")
}
callInfo := struct {
Name string
}{
Name: name,
}
mock.lockStop.Lock()
mock.calls.Stop = append(mock.calls.Stop, callInfo)
mock.lockStop.Unlock()
return mock.StopFunc(name)
}
// StopCalls gets all the calls that were made to Stop.
// Check the length with:
//
// len(mockedSensorController.StopCalls())
func (mock *SensorControllerMock) StopCalls() []struct {
Name string
} {
var calls []struct {
Name string
}
mock.lockStop.RLock()
calls = mock.calls.Stop
mock.lockStop.RUnlock()
return calls
}
// Ensure, that MQTTControllerMock does implement MQTTController.
// If this is not the case, regenerate this file with moq.
var _ MQTTController = &MQTTControllerMock{}
// MQTTControllerMock is a mock implementation of MQTTController.
//
// func TestSomethingThatUsesMQTTController(t *testing.T) {
//
// // make and configure a mocked MQTTController
// mockedMQTTController := &MQTTControllerMock{
// ConfigsFunc: func() []*mqttapi.Msg {
// panic("mock out the Configs method")
// },
// MsgsFunc: func() chan *mqttapi.Msg {
// panic("mock out the Msgs method")
// },
// SubscriptionsFunc: func() []*mqttapi.Subscription {
// panic("mock out the Subscriptions method")
// },
// }
//
// // use mockedMQTTController in code that requires MQTTController
// // and then make assertions.
//
// }
type MQTTControllerMock struct {
// ConfigsFunc mocks the Configs method.
ConfigsFunc func() []*mqttapi.Msg
// MsgsFunc mocks the Msgs method.
MsgsFunc func() chan *mqttapi.Msg
// SubscriptionsFunc mocks the Subscriptions method.
SubscriptionsFunc func() []*mqttapi.Subscription
// calls tracks calls to the methods.
calls struct {
// Configs holds details about calls to the Configs method.
Configs []struct {
}
// Msgs holds details about calls to the Msgs method.
Msgs []struct {
}
// Subscriptions holds details about calls to the Subscriptions method.
Subscriptions []struct {
}
}
lockConfigs sync.RWMutex
lockMsgs sync.RWMutex
lockSubscriptions sync.RWMutex
}
// Configs calls ConfigsFunc.
func (mock *MQTTControllerMock) Configs() []*mqttapi.Msg {
if mock.ConfigsFunc == nil {
panic("MQTTControllerMock.ConfigsFunc: method is nil but MQTTController.Configs was just called")
}
callInfo := struct {
}{}
mock.lockConfigs.Lock()
mock.calls.Configs = append(mock.calls.Configs, callInfo)
mock.lockConfigs.Unlock()
return mock.ConfigsFunc()
}
// ConfigsCalls gets all the calls that were made to Configs.
// Check the length with:
//
// len(mockedMQTTController.ConfigsCalls())
func (mock *MQTTControllerMock) ConfigsCalls() []struct {
} {
var calls []struct {
}
mock.lockConfigs.RLock()
calls = mock.calls.Configs
mock.lockConfigs.RUnlock()
return calls
}
// Msgs calls MsgsFunc.
func (mock *MQTTControllerMock) Msgs() chan *mqttapi.Msg {
if mock.MsgsFunc == nil {
panic("MQTTControllerMock.MsgsFunc: method is nil but MQTTController.Msgs was just called")
}
callInfo := struct {
}{}
mock.lockMsgs.Lock()
mock.calls.Msgs = append(mock.calls.Msgs, callInfo)
mock.lockMsgs.Unlock()
return mock.MsgsFunc()
}
// MsgsCalls gets all the calls that were made to Msgs.
// Check the length with:
//
// len(mockedMQTTController.MsgsCalls())
func (mock *MQTTControllerMock) MsgsCalls() []struct {
} {
var calls []struct {
}
mock.lockMsgs.RLock()
calls = mock.calls.Msgs
mock.lockMsgs.RUnlock()
return calls
}
// Subscriptions calls SubscriptionsFunc.
func (mock *MQTTControllerMock) Subscriptions() []*mqttapi.Subscription {
if mock.SubscriptionsFunc == nil {
panic("MQTTControllerMock.SubscriptionsFunc: method is nil but MQTTController.Subscriptions was just called")
}
callInfo := struct {
}{}
mock.lockSubscriptions.Lock()
mock.calls.Subscriptions = append(mock.calls.Subscriptions, callInfo)
mock.lockSubscriptions.Unlock()
return mock.SubscriptionsFunc()
}
// SubscriptionsCalls gets all the calls that were made to Subscriptions.
// Check the length with:
//
// len(mockedMQTTController.SubscriptionsCalls())
func (mock *MQTTControllerMock) SubscriptionsCalls() []struct {
} {
var calls []struct {
}
mock.lockSubscriptions.RLock()
calls = mock.calls.Subscriptions
mock.lockSubscriptions.RUnlock()
return calls
}