1
0
Fork 0
hswro-alarm-bot/test_utils.go

40 lines
1.0 KiB
Go
Raw Normal View History

package main
2025-01-06 20:38:43 +00:00
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}},
}
}
2025-01-06 13:55:08 +00:00
func makeGenericMessage(changeType satel.ChangeType, index int, val bool) GenericMessage {
return GenericMessage{[]satel.BasicEventElement{{Type: changeType, Index: index, Value: val}}}
}
2025-01-06 20:38:43 +00:00
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
}