Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
0xERR0R committed Sep 8, 2021
1 parent af3a950 commit ea3b5de
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions util/bootstrap_test.go
Original file line number Diff line number Diff line change
@@ -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,
},
})
})
})
})

})

})

0 comments on commit ea3b5de

Please sign in to comment.