up coverage
This commit is contained in:
parent
2c8dd7608b
commit
be8c288839
1 changed files with 9 additions and 19 deletions
|
@ -13,28 +13,18 @@ func TestParseRequest(t *testing.T) {
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
query string
|
query string
|
||||||
qtype uint16
|
|
||||||
expected string // output from r.String()
|
expected string // output from r.String()
|
||||||
}{
|
}{
|
||||||
{
|
|
||||||
// valid SRV request
|
// valid SRV request
|
||||||
"_http._tcp.webs.mynamespace.svc.inter.webs.test.", dns.TypeSRV,
|
{"_http._tcp.webs.mynamespace.svc.inter.webs.test.", "http.tcp..webs.mynamespace.svc"},
|
||||||
"http.tcp..webs.mynamespace.svc",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
// wildcard acceptance
|
// wildcard acceptance
|
||||||
"*.any.*.any.svc.inter.webs.test.", dns.TypeSRV,
|
{"*.any.*.any.svc.inter.webs.test.", "*.any..*.any.svc"},
|
||||||
"*.any..*.any.svc",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
// A request of endpoint
|
// A request of endpoint
|
||||||
"1-2-3-4.webs.mynamespace.svc.inter.webs.test.", dns.TypeA,
|
{"1-2-3-4.webs.mynamespace.svc.inter.webs.test.", "*.*.1-2-3-4.webs.mynamespace.svc"},
|
||||||
"*.*.1-2-3-4.webs.mynamespace.svc",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
for i, tc := range tests {
|
for i, tc := range tests {
|
||||||
m := new(dns.Msg)
|
m := new(dns.Msg)
|
||||||
m.SetQuestion(tc.query, tc.qtype)
|
m.SetQuestion(tc.query, dns.TypeA)
|
||||||
state := request.Request{Zone: zone, Req: m}
|
state := request.Request{Zone: zone, Req: m}
|
||||||
|
|
||||||
r, e := k.parseRequest(state)
|
r, e := k.parseRequest(state)
|
||||||
|
@ -53,7 +43,7 @@ func TestParseInvalidRequest(t *testing.T) {
|
||||||
|
|
||||||
invalid := []string{
|
invalid := []string{
|
||||||
"webs.mynamespace.pood.inter.webs.test.", // Request must be for pod or svc subdomain.
|
"webs.mynamespace.pood.inter.webs.test.", // Request must be for pod or svc subdomain.
|
||||||
"too.long.for.what.I.am.trying.to.do.inter.webs.tests.", // Too long.
|
"too.long.for.what.I.am.trying.to.pod.inter.webs.tests.", // Too long.
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, query := range invalid {
|
for i, query := range invalid {
|
||||||
|
|
Loading…
Add table
Reference in a new issue