40 lines
1.0 KiB
Go
40 lines
1.0 KiB
Go
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
|
|
}
|
|
|
|
func (self *MockTgBotAPI) Send(c tgbotapi.Chattable) (tgbotapi.Message, error) {
|
|
self.messages = append(self.messages, c)
|
|
return tgbotapi.Message{}, nil
|
|
}
|
|
|
|
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
|
|
}
|