-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathInMemoryBackend_test.go
More file actions
37 lines (29 loc) · 869 Bytes
/
Copy pathInMemoryBackend_test.go
File metadata and controls
37 lines (29 loc) · 869 Bytes
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
package gospam_test
import (
"testing"
"github.com/jonas-koeritz/gospam"
)
func TestSubdomains(t *testing.T) {
backend := &gospam.InMemoryBackend{
MaxStoredMessage: 100,
AcceptedDomains: []string{"example.com"},
AcceptSubdomains: true,
}
if backend.IsAcceptedDomain("sub.example.com") == false {
t.Errorf("subdomain not accepted when it should've been")
}
if backend.IsAcceptedDomain("example.com") == false {
t.Errorf("domain not accepted when it should've been")
}
backend = &gospam.InMemoryBackend{
MaxStoredMessage: 100,
AcceptedDomains: []string{"example.com"},
AcceptSubdomains: false,
}
if backend.IsAcceptedDomain("sub.example.com") == true {
t.Errorf("subdomain accepted when it shouldn't have been")
}
if backend.IsAcceptedDomain("example.com") == false {
t.Errorf("domain not accepted when it should've been")
}
}