-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsinksmtp_test.go
54 lines (47 loc) · 1.06 KB
/
sinksmtp_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
47
48
49
50
51
52
53
54
//
// Basic testing for file loading, which is stuck in sinksmtp.go for
// reasons that are partly historical.
package main
import (
"bufio"
"sort"
"strings"
"testing"
)
func isPresent(a []string, p string) bool {
i := sort.SearchStrings(a, p)
return i < len(a) && a[i] == p
}
// Test readList() by loading a basic list and seeing if the entries we
// expect are present and have been properly lower-cased.
func TestLoader(t *testing.T) {
reader := bufio.NewReader(strings.NewReader(basiclist))
a, err := readList(reader)
if err != nil {
t.Fatalf("Error during read: %v", err)
}
sort.Strings(a)
for _, p := range present {
if !isPresent(a, p) {
t.Fatalf("Missing a record: %s", p)
}
}
if isPresent(a, "") {
t.Fatalf("Blank line present in address list.")
}
if isPresent(a, "# t") {
t.Fatalf("Comment present in address list.")
}
}
var basiclist = `# This is a comment
root@
@example.com
@.barney.net
# t
`
var present = []string{
"[email protected]", "root@", "@example.com", "[email protected]",
"@.barney.net",
}