Skip to content

Commit

Permalink
test(bootstrap): add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
0xERR0R authored and ThinkChaos committed Dec 15, 2022
1 parent 94e34f9 commit 1e14e06
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,15 +261,15 @@ var _ = Describe("Config", func() {
})

When("bootstrapDns is defined", func() {
It("should be backwards compatible", func() {
It("should be backwards compatible to 'single IP syntax'", func() {
cfg := Config{}
data := "bootstrapDns: 0.0.0.0"

err := unmarshalConfig([]byte(data), &cfg)
Expect(err).ShouldNot(HaveOccurred())
Expect(cfg.BootstrapDNS[0].Upstream.Host).Should(Equal("0.0.0.0"))
})
It("should be backwards compatible", func() {
It("should be backwards compatible to 'single item definition'", func() {
cfg := Config{}
data := `
bootstrapDns:
Expand All @@ -282,6 +282,24 @@ bootstrapDns:
Expect(cfg.BootstrapDNS[0].Upstream.Host).Should(Equal("dns.example.com"))
Expect(cfg.BootstrapDNS[0].IPs).Should(HaveLen(1))
})
It("should process list of bootstrap items", func() {
cfg := Config{}
data := `
bootstrapDns:
- upstream: tcp-tls:dns.example.com
ips:
- 0.0.0.0
- upstream: 1.2.3.4
`
err := unmarshalConfig([]byte(data), &cfg)
Expect(err).ShouldNot(HaveOccurred())
Expect(cfg.BootstrapDNS).Should(HaveLen(2))
Expect(cfg.BootstrapDNS[0].Upstream.Host).Should(Equal("dns.example.com"))
Expect(cfg.BootstrapDNS[0].Upstream.Net).Should(Equal(NetProtocolTcpTls))
Expect(cfg.BootstrapDNS[0].IPs).Should(HaveLen(1))
Expect(cfg.BootstrapDNS[1].Upstream.Host).Should(Equal("1.2.3.4"))
Expect(cfg.BootstrapDNS[1].Upstream.Net).Should(Equal(NetProtocolTcpUdp))
})
})

When("config is not YAML", func() {
Expand Down

0 comments on commit 1e14e06

Please sign in to comment.