ScuttleBot

scuttlebot / internal / bots / snitch / snitch_test.go
Source Blame History 39 lines
5ac549c… lmata 1 package snitch_test
5ac549c… lmata 2
5ac549c… lmata 3 import (
5ac549c… lmata 4 "testing"
5ac549c… lmata 5 "time"
5ac549c… lmata 6
5ac549c… lmata 7 "github.com/conflicthq/scuttlebot/internal/bots/snitch"
5ac549c… lmata 8 )
5ac549c… lmata 9
5ac549c… lmata 10 func TestNewBotDefaults(t *testing.T) {
5ac549c… lmata 11 b := snitch.New(snitch.Config{IRCAddr: "127.0.0.1:6667"}, nil)
5ac549c… lmata 12 if b == nil {
5ac549c… lmata 13 t.Fatal("New returned nil")
5ac549c… lmata 14 }
5ac549c… lmata 15 }
5ac549c… lmata 16
5ac549c… lmata 17 func TestNewBotCustomThresholds(t *testing.T) {
5ac549c… lmata 18 cfg := snitch.Config{
5ac549c… lmata 19 IRCAddr: "127.0.0.1:6667",
5ac549c… lmata 20 Nick: "snitch",
5ac549c… lmata 21 Password: "pw",
5ac549c… lmata 22 FloodMessages: 5,
5ac549c… lmata 23 FloodWindow: 2 * time.Second,
5ac549c… lmata 24 JoinPartThreshold: 3,
5ac549c… lmata 25 JoinPartWindow: 10 * time.Second,
5ac549c… lmata 26 }
5ac549c… lmata 27 b := snitch.New(cfg, nil)
5ac549c… lmata 28 if b == nil {
5ac549c… lmata 29 t.Fatal("New returned nil")
5ac549c… lmata 30 }
5ac549c… lmata 31 }
5ac549c… lmata 32
5ac549c… lmata 33 func TestMultipleBotInstancesAreDistinct(t *testing.T) {
5ac549c… lmata 34 b1 := snitch.New(snitch.Config{IRCAddr: "127.0.0.1:6667", Nick: "snitch1"}, nil)
5ac549c… lmata 35 b2 := snitch.New(snitch.Config{IRCAddr: "127.0.0.1:6667", Nick: "snitch2"}, nil)
5ac549c… lmata 36 if b1 == b2 {
5ac549c… lmata 37 t.Error("expected distinct bot instances")
5ac549c… lmata 38 }
5ac549c… lmata 39 }

Keyboard Shortcuts

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