Skip to content

Commit

Permalink
test: add unittest for DisableQTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
wolf-joe committed Oct 12, 2020
1 parent 3769b65 commit 606f1f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/conf/conf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ func TestNewHandler(t *testing.T) {
p := gomonkey.ApplyFunc(toml.DecodeFile,
func(fn string, conf interface{}) (toml.MetaData, error) {
conf.(*Conf).DisableIPv6 = true
conf.(*Conf).DisableQTypes = []string{"HTTPS"}
conf.(*Conf).Listen = ":53/tcp"
return toml.MetaData{}, nil
})
Expand Down
7 changes: 7 additions & 0 deletions inbound/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ func TestHandler(t *testing.T) {
assert.NotNil(t, writer.r)
assert.Equal(t, len(writer.r.Answer), 0)

// 测试DisableIPv6
handler.DisableIPv6 = false
handler.DisableQTypes = map[string]bool{"AAAA": true}
handler.ServeDNS(writer, req)
assert.NotNil(t, writer.r)
assert.Equal(t, len(writer.r.Answer), 0)

req.SetQuestion("ip.cn.", dns.TypeA)

mocker := mock.Mocker{}
Expand Down

0 comments on commit 606f1f2

Please sign in to comment.