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

222 lines
6.5 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/preferences"
"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
}