package main import ( "git.sr.ht/~michalr/go-satel" tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5" ) func makeTestSatelEvent(changeType satel.ChangeType, index int, val bool) satel.Event { return satel.Event{ BasicEvents: []satel.BasicEventElement{{Type: changeType, Index: index, Value: val}}, } } func makeGenericMessage(changeType satel.ChangeType, index int, val bool) GenericMessage { return GenericMessage{[]satel.BasicEventElement{{Type: changeType, Index: index, Value: val}}} } type MockTgBotAPI struct { messages []tgbotapi.Chattable updates chan tgbotapi.Update } func MakeMockTgBotAPI() *MockTgBotAPI { return &MockTgBotAPI{messages: []tgbotapi.Chattable{}, updates: make(chan tgbotapi.Update)} } func (botMock *MockTgBotAPI) Send(c tgbotapi.Chattable) (tgbotapi.Message, error) { botMock.messages = append(botMock.messages, c) return tgbotapi.Message{}, nil } func (botMock *MockTgBotAPI) GetUpdatesChan(u tgbotapi.UpdateConfig) tgbotapi.UpdatesChannel { return botMock.updates } func (botMock *MockTgBotAPI) StopReceivingUpdates() { close(botMock.updates) } type MockSatelNameGetter struct { name string } func (self MockSatelNameGetter) GetName(devType satel.DeviceType, index byte) (*satel.NameEvent, error) { retval := satel.NameEvent{ DevType: devType, DevNumber: index, DevTypeFunction: 0, DevName: self.name, } return &retval, nil }