forked from ccnmtl/hound
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalertscollection_test.go
46 lines (37 loc) · 1.03 KB
/
alertscollection_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"testing"
)
func Test_intmin(t *testing.T) {
if intmin(1, 2) != 1 {
t.Error("wrong")
}
if intmin(2, 1) != 1 {
t.Error("wrong")
}
}
type DummyEmailer struct{}
func (d DummyEmailer) Throttled(failures, globalThrottle int, emailTo string) {}
func (d DummyEmailer) RecoveryThrottled(recoveriesSent, globalThrottle int, emailTo string) {}
func (d DummyEmailer) EncounteredErrors(errors int, emailTo string) {}
func Test_emptyAlertsCollection(t *testing.T) {
ac := newAlertsCollection(DummyEmailer{})
ac.processAll()
ac.DisplayAll()
ac.MakePageResponse()
}
func Test_handleErrors(t *testing.T) {
ac := newAlertsCollection(DummyEmailer{})
ac.handleErrors(1)
}
func Test_addAlert(t *testing.T) {
ac := newAlertsCollection(DummyEmailer{})
a := newAlert("foo", "foo", "", 10, "above", DummyFetcher{}, "[email protected]", "")
ac.addAlert(a)
ac.DisplayAll()
ac.MakePageResponse()
retrieved := ac.byHash(a.Hash())
if retrieved != a {
t.Error("failed to retrieve alert")
}
}