diff --git a/util/bootstrap_test.go b/util/bootstrap_test.go new file mode 100644 index 000000000..e29334f2e --- /dev/null +++ b/util/bootstrap_test.go @@ -0,0 +1,50 @@ +package util + +import ( + "github.com/0xERR0R/blocky/config" + "github.com/0xERR0R/blocky/helpertest" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + "golang.org/x/net/context" +) + +var _ = Describe("Bootstrap resolver configuration", func() { + Describe("Default config", func() { + When("BootstrapDns is not configured", func() { + dialer := Dialer(&config.Config{}) + It("should return a dealer without custom resolver", func() { + Expect(dialer.Resolver).Should(BeNil()) + }) + }) + When("BootstrapDns is configured UDP resolver", func() { + dialer := Dialer(&config.Config{ + BootstrapDNS: config.Upstream{ + Net: config.NetTCPUDP, + Host: "0.0.0.0", + Port: 53, + }, + }) + It("should return a dealer with custom resolver", func() { + Expect(dialer.Resolver).Should(Not(BeNil())) + _, err := dialer.Resolver.Dial(context.Background(), "udp", "test") + Expect(err).Should(Succeed()) + }) + }) + + When("BootstrapDns has wrong (https) configuration", func() { + It("should log fatal error", func() { + helpertest.ShouldLogFatal(func() { + Dialer(&config.Config{ + BootstrapDNS: config.Upstream{ + Net: config.NetHTTPS, + Host: "1.1.1.1", + Port: 53, + }, + }) + }) + }) + }) + + }) + +})