text: "Done.",
},
{
- name: "user message not shown",
- event: Event{Kind: "user", Text: "typed"},
+ name: "own user message not shown",
+ event: Event{Kind: "user", Text: "typed", Source: terminalSource},
text: "",
},
+ {
+ name: "user message of another source marked",
+ event: Event{Kind: "user", Text: "from the phone", Source: "telegram"},
+ text: "[telegram] from the phone",
+ },
{
name: "long result cut",
event: Event{Kind: "echo", Text: strings.Repeat("line\n", 12)},
func startTestDaemon(t *testing.T, server *fakeResponses) string {
t.Helper()
+ return startTestDaemonWithBot(t, server, nil)
+}
+
+// startTestDaemonWithBot is startTestDaemon with bot, which can be nil.
+func startTestDaemonWithBot(t *testing.T, server *fakeResponses, bot *TelegramBot) string {
+ t.Helper()
+
dir := t.TempDir()
agent, err := openAgent(filepath.Join(dir, agentDirName))
require.NoError(t, err)
ctx, cancel := context.WithCancel(t.Context())
done := make(chan error)
go func() {
- done <- serveAgent(ctx, listener, func(notify func(Event)) (*loop, error) {
+ done <- serveAgent(ctx, listener, bot, func(notify func(Event)) (*loop, error) {
return newLoop(agent, memory, client, clock.Now, notify)
})
}()