Add another test

This commit is contained in:
Roland Shoemaker 2015-08-18 14:29:18 -07:00
parent 7151c3cefb
commit 00a83e49a1
1 changed files with 10 additions and 3 deletions

View File

@ -20,26 +20,30 @@ var (
Host: "b.com",
Type: blacklisted,
}
rC = DomainRule{
Host: "d.c.com",
Type: blacklisted,
}
)
func TestLoadAndDump(t *testing.T) {
p, err := NewPolicyAuthorityDatabaseImpl(dbConnStr)
test.AssertNotError(t, err, "Couldn't create PADB")
err = p.LoadRules([]DomainRule{rA, rB})
err = p.LoadRules([]DomainRule{rA, rB, rC})
test.AssertNotError(t, err, "Couldn't load rules")
r, err := p.DumpRules()
test.AssertNotError(t, err, "Couldn't dump rules")
test.AssertEquals(t, len(r), 2)
test.AssertEquals(t, len(r), 3)
}
func TestGet(t *testing.T) {
p, err := NewPolicyAuthorityDatabaseImpl(dbConnStr)
test.AssertNotError(t, err, "Couldn't create PADB")
err = p.LoadRules([]DomainRule{rA, rB})
err = p.LoadRules([]DomainRule{rA, rB, rC})
test.AssertNotError(t, err, "Couldn't load rules")
err = p.CheckRules("b.com", false)
@ -61,4 +65,7 @@ func TestGet(t *testing.T) {
test.AssertNotError(t, err, "Hostname should not be blacklisted")
err = p.CheckRules(".b.com", false)
test.AssertError(t, err, "Hostname should be blacklisted")
err = p.CheckRules("e.d.c.com", false)
test.AssertError(t, err, "Hostname should be blacklisted")
}