40 lines
863 B
Go
40 lines
863 B
Go
package main
|
|
|
|
import (
|
|
"html/template"
|
|
"io"
|
|
"log"
|
|
"os"
|
|
"sync"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestCommandHandler_DoesNothing(t *testing.T) {
|
|
f, err := os.CreateTemp("", "TestSatelLastSeenFiltering")
|
|
assert.NoError(t, err)
|
|
tempFileName := f.Name()
|
|
assert.NoError(t, f.Close())
|
|
defer os.Remove(f.Name())
|
|
|
|
fakeLog := log.New(io.Discard, "", log.Ltime)
|
|
ds := MakeDataStore(fakeLog, tempFileName)
|
|
wg := sync.WaitGroup{}
|
|
|
|
mockBot := MakeMockTgBotAPI()
|
|
mockSatel := MockSatelNameGetter{"test"}
|
|
tpl := template.Must(template.New("IRCMessage").Parse(IRCMessageTemplate))
|
|
config := AppConfig{}
|
|
config.AllowedIndexes = []int{}
|
|
config.AllowedTypes = []SatelChangeType{}
|
|
|
|
wg.Add(1)
|
|
go func() {
|
|
HandleTelegramCommands(mockBot, fakeLog, &ds, config, tpl, &mockSatel)
|
|
wg.Done()
|
|
}()
|
|
mockBot.StopReceivingUpdates()
|
|
wg.Wait()
|
|
}
|