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