ScuttleBot

scuttlebot / internal / bots / systembot / systembot_test.go
Blame History Raw 72 lines
1
package systembot_test
2
3
import (
4
"testing"
5
"time"
6
7
"github.com/conflicthq/scuttlebot/internal/bots/systembot"
8
)
9
10
func TestMemoryStoreAppendAndAll(t *testing.T) {
11
s := &systembot.MemoryStore{}
12
s.Append(systembot.Entry{Kind: systembot.KindNotice, Nick: "NickServ", Text: "Password accepted"})
13
s.Append(systembot.Entry{Kind: systembot.KindJoin, Channel: "#fleet", Nick: "agent-01"})
14
15
entries := s.All()
16
if len(entries) != 2 {
17
t.Fatalf("expected 2 entries, got %d", len(entries))
18
}
19
if entries[0].Kind != systembot.KindNotice {
20
t.Errorf("entry 0 kind: got %q, want %q", entries[0].Kind, systembot.KindNotice)
21
}
22
if entries[1].Kind != systembot.KindJoin {
23
t.Errorf("entry 1 kind: got %q, want %q", entries[1].Kind, systembot.KindJoin)
24
}
25
}
26
27
func TestEntryKinds(t *testing.T) {
28
kinds := []systembot.EntryKind{
29
systembot.KindNotice,
30
systembot.KindJoin,
31
systembot.KindPart,
32
systembot.KindQuit,
33
systembot.KindKick,
34
systembot.KindMode,
35
}
36
s := &systembot.MemoryStore{}
37
for _, k := range kinds {
38
if err := s.Append(systembot.Entry{Kind: k, At: time.Now()}); err != nil {
39
t.Errorf("Append %q: %v", k, err)
40
}
41
}
42
if got := len(s.All()); got != len(kinds) {
43
t.Errorf("expected %d entries, got %d", len(kinds), got)
44
}
45
}
46
47
func TestBotNameAndNew(t *testing.T) {
48
b := systembot.New("localhost:6667", "pass", []string{"#fleet"}, &systembot.MemoryStore{}, nil)
49
if b == nil {
50
t.Fatal("expected non-nil bot")
51
}
52
if b.Name() != "systembot" {
53
t.Errorf("Name(): got %q, want systembot", b.Name())
54
}
55
}
56
57
func TestPrivmsgIsNotLogged(t *testing.T) {
58
// systembot does not have a PRIVMSG handler — this is a design invariant.
59
// Verify that NOTICE and connection events ARE the only logged kinds.
60
// (The bot itself doesn't expose a direct way to inject events — this is
61
// a documentation test confirming the design intent.)
62
_ = []systembot.EntryKind{
63
systembot.KindNotice,
64
systembot.KindJoin,
65
systembot.KindPart,
66
systembot.KindQuit,
67
systembot.KindKick,
68
systembot.KindMode,
69
}
70
// PRIVMSG is NOT in the list — systembot should never log agent message stream events.
71
}
72

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button