You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gdns/upstream_test.go

44 lines
1014 B
Go

package main
import (
"testing"
)
func TestServerMathNil(t *testing.T) {
srv := UpstreamServer{} // initial with nil
domains := []string{"twitter.com", "google.com", "abc.com"}
for _, d := range domains {
if srv.match(d) {
t.Errorf("%s must match in false result\n", d)
}
}
}
func TestServerMatch(t *testing.T) {
d := Kv{"twitter.com": 1, "google.com": 1}
srv := UpstreamServer{domains: d}
test_domains := map[string]bool{
"twitter.com": true,
"pbs.twitter.com": true,
"abc.pbs.twitter.com": true,
"efg.abc.pbs.twitter.com": true,
"google.com": true,
"plus.google.com": true,
"cc.plus.google.com": true,
"dd.cc.plus.google.com": true,
"twitter.abc.com": false,
"twitter.com.aa.com": false,
"google.com.cccc.com": false,
"google.com.aeddasdfc3.com": false,
}
for d, r := range test_domains {
if srv.match(d) != r {
t.Errorf("%s must match in %v result\n", d, r)
}
}
}