diff --git a/config/config_test.go b/config/config_test.go index c2aba5a8..fbbbfb26 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -165,7 +165,7 @@ var _ = Describe("Config", func() { When("Test file does not exist", func() { It("should fail", func() { _, err := LoadConfig(tmpDir.JoinPath("config-does-not-exist.yaml"), true) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) }) }) When("Multiple config files are used", func() { @@ -199,7 +199,7 @@ var _ = Describe("Config", func() { When("Config folder does not exist", func() { It("should fail", func() { _, err := LoadConfig(tmpDir.JoinPath("does-not-exist-config/"), true) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) }) }) When("config file is malformed", func() { @@ -766,7 +766,7 @@ bootstrapDns: } _, err := WithDefaults[T]() - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) }) }) }) diff --git a/lists/parsers/filtererrors_test.go b/lists/parsers/filtererrors_test.go index 001552e6..d3b67323 100644 --- a/lists/parsers/filtererrors_test.go +++ b/lists/parsers/filtererrors_test.go @@ -34,7 +34,7 @@ var _ = Describe("errorFilter", func() { Expect(parser.Position()).Should(Equal("call 1")) _, err = parser.Next(context.Background()) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(err).Should(MatchError(ErrTooManyErrors)) Expect(parser.Position()).Should(Equal("call 2")) }) @@ -53,7 +53,7 @@ var _ = Describe("errorFilter", func() { Expect(parser.Position()).Should(Equal("call 3")) _, err = parser.Next(context.Background()) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(err).Should(MatchError(ErrTooManyErrors)) Expect(parser.Position()).Should(Equal("call 4")) }) @@ -76,7 +76,7 @@ var _ = Describe("errorFilter", func() { Expect(parser.Position()).Should(Equal("call 5")) _, err = parser.Next(context.Background()) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(err).Should(MatchError(io.EOF)) Expect(IsNonResumableErr(err)).Should(BeTrue()) Expect(parser.Position()).Should(Equal("call 7")) @@ -106,7 +106,7 @@ var _ = Describe("errorFilter", func() { Expect(parser.Position()).Should(Equal("call 2")) _, err = parser.Next(context.Background()) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(err).Should(MatchError(io.EOF)) Expect(IsNonResumableErr(err)).Should(BeTrue()) diff --git a/lists/parsers/hosts_test.go b/lists/parsers/hosts_test.go index 1c132d5a..425a7129 100644 --- a/lists/parsers/hosts_test.go +++ b/lists/parsers/hosts_test.go @@ -77,7 +77,7 @@ var _ = Describe("Hosts", func() { Expect(sut.Position()).Should(Equal("line 9")) _, err = sut.Next(context.Background()) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(err).Should(MatchError(io.EOF)) Expect(IsNonResumableErr(err)).Should(BeTrue()) Expect(sut.Position()).Should(Equal("line 10")) @@ -98,7 +98,7 @@ var _ = Describe("Hosts", func() { sut := Hosts(strings.NewReader(line)) _, err := sut.Next(context.Background()) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(IsNonResumableErr(err)).ShouldNot(BeTrue()) Expect(sut.Position()).Should(Equal("line 1")) } @@ -138,7 +138,7 @@ var _ = Describe("Hosts", func() { err := entry.forEachHost(func(host string) error { return expectedErr }) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(err).Should(MatchError(expectedErr)) }) }) @@ -193,7 +193,7 @@ var _ = Describe("HostsFile", func() { Expect(sut.Position()).Should(Equal("line 5")) _, err = sut.Next(context.Background()) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(err).Should(MatchError(io.EOF)) Expect(IsNonResumableErr(err)).Should(BeTrue()) Expect(sut.Position()).Should(Equal("line 6")) @@ -215,7 +215,7 @@ var _ = Describe("HostsFile", func() { Expect(sut.Position()).Should(Equal("line 1")) _, err = sut.Next(context.Background()) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(err).Should(MatchError(io.EOF)) Expect(IsNonResumableErr(err)).Should(BeTrue()) Expect(sut.Position()).Should(Equal("line 2")) @@ -237,7 +237,7 @@ var _ = Describe("HostsFile", func() { sut := HostsFile(strings.NewReader(line)) _, err := sut.Next(context.Background()) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(IsNonResumableErr(err)).ShouldNot(BeTrue()) Expect(sut.Position()).Should(Equal("line 1")) } @@ -271,7 +271,7 @@ var _ = Describe("HostsFile", func() { err := entry.forEachHost(func(host string) error { return expectedErr }) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(err).Should(MatchError(expectedErr)) }) }) @@ -291,7 +291,7 @@ var _ = Describe("HostsFile", func() { return expectedErr }) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(err).Should(MatchError(expectedErr)) }) }) @@ -376,7 +376,7 @@ var _ = Describe("HostList", func() { Expect(sut.Position()).Should(Equal("line 10")) _, err = sut.Next(context.Background()) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(err).Should(MatchError(io.EOF)) Expect(IsNonResumableErr(err)).Should(BeTrue()) Expect(sut.Position()).Should(Equal("line 11")) @@ -396,7 +396,7 @@ var _ = Describe("HostList", func() { sut := HostList(strings.NewReader(line)) _, err := sut.Next(context.Background()) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(IsNonResumableErr(err)).ShouldNot(BeTrue()) Expect(sut.Position()).Should(Equal("line 1")) } @@ -430,7 +430,7 @@ var _ = Describe("HostList", func() { err := entry.forEachHost(func(host string) error { return expectedErr }) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(err).Should(MatchError(expectedErr)) }) }) diff --git a/lists/parsers/lines_test.go b/lists/parsers/lines_test.go index 8999b190..ecc47b01 100644 --- a/lists/parsers/lines_test.go +++ b/lists/parsers/lines_test.go @@ -56,7 +56,7 @@ var _ = Describe("Lines", func() { Expect(sut.Position()).Should(Equal("line 3")) _, err = sut.Next(context.Background()) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(err).Should(MatchError(io.EOF)) Expect(IsNonResumableErr(err)).Should(BeTrue()) Expect(sut.Position()).Should(Equal("line 4")) @@ -75,7 +75,7 @@ var _ = Describe("Lines", func() { It("skips them", func() { _, err := sut.Next(context.Background()) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(err).Should(MatchError(io.EOF)) Expect(IsNonResumableErr(err)).Should(BeTrue()) Expect(sut.Position()).Should(Equal("line 5")) @@ -135,7 +135,7 @@ var _ = Describe("Lines", func() { It("fails", func() { _, err := sut.Next(context.Background()) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(sut.Position()).Should(Equal("line 1")) }) }) @@ -160,7 +160,7 @@ var _ = Describe("Lines", func() { cancel() _, err = sut.Next(ctx) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(IsNonResumableErr(err)).Should(BeTrue()) Expect(sut.Position()).Should(Equal("line 2")) }) diff --git a/lists/parsers/parser_test.go b/lists/parsers/parser_test.go index 85be936a..c61058b0 100644 --- a/lists/parsers/parser_test.go +++ b/lists/parsers/parser_test.go @@ -35,7 +35,7 @@ var _ = Describe("ForEach", func() { err := ForEach(context.Background(), lines, func(line string) error { return expectedErr }) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(err).Should(MatchError(expectedErr)) Expect(err.Error()).Should(HavePrefix("line 1: ")) }) @@ -50,7 +50,7 @@ var _ = Describe("ForEach", func() { return nil }) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(err.Error()).Should(HavePrefix("line 1: ")) }) @@ -66,7 +66,7 @@ var _ = Describe("ForEach", func() { return nil }) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(err).Should(MatchError(context.Canceled)) Expect(err.Error()).Should(HavePrefix("line 1: ")) }) @@ -80,7 +80,7 @@ var _ = Describe("ForEach", func() { return nil }) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(err).Should(MatchError(context.Canceled)) Expect(err.Error()).Should(HavePrefix("line 0: ")) }) @@ -99,14 +99,14 @@ var _ = Describe("ErrWithPosition", func() { Expect(err).Should(Succeed()) err = ErrWithPosition(lines, inner) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(err.Error()).Should(Equal("line 1: inner")) _, err = lines.Next(context.Background()) Expect(err).Should(Succeed()) err = ErrWithPosition(lines, inner) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(err.Error()).Should(Equal("line 2: inner")) }) }) diff --git a/resolver/bootstrap_test.go b/resolver/bootstrap_test.go index 4d2b65ba..4dcf972d 100644 --- a/resolver/bootstrap_test.go +++ b/resolver/bootstrap_test.go @@ -73,7 +73,7 @@ var _ = Describe("Bootstrap", Label("bootstrap"), func() { } _, err := sut.resolveUpstream(ctx, nil, "example.com") - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(usedSystemResolver).Should(Receive(BeTrue())) }) @@ -105,7 +105,7 @@ var _ = Describe("Bootstrap", Label("bootstrap"), func() { } _, err := NewBootstrap(ctx, &cfg) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) }) }) }) @@ -147,7 +147,7 @@ var _ = Describe("Bootstrap", Label("bootstrap"), func() { } _, err := NewBootstrap(ctx, &cfg) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(err.Error()).Should(ContainSubstring("must use IP instead of hostname")) }) }) @@ -191,7 +191,7 @@ var _ = Describe("Bootstrap", Label("bootstrap"), func() { } _, err := NewBootstrap(ctx, &cfg) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(err.Error()).Should(ContainSubstring("no IPs configured")) }) }) @@ -285,7 +285,7 @@ var _ = Describe("Bootstrap", Label("bootstrap"), func() { ips, err := sut.resolve(ctx, "localhost", []dns.Type{A}) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(err.Error()).Should(ContainSubstring(resolveErr.Error())) Expect(ips).Should(BeEmpty()) }) @@ -299,7 +299,7 @@ var _ = Describe("Bootstrap", Label("bootstrap"), func() { ips, err := sut.resolve(ctx, "unknownhost.invalid", []dns.Type{A}) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(err.Error()).Should(ContainSubstring("no such host")) Expect(ips).Should(BeEmpty()) }) @@ -374,7 +374,7 @@ var _ = Describe("Bootstrap", Label("bootstrap"), func() { // implicit expectation of 0 bootstrapUpstream.Resolve calls _, err = t.DialContext(ctx, "ip", "!bad-addr!") - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) }) It("returns upstream errors", func() { @@ -386,7 +386,7 @@ var _ = Describe("Bootstrap", Label("bootstrap"), func() { _, err = t.DialContext(ctx, "ip", "abc:123") - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(err.Error()).Should(ContainSubstring(resolveErr.Error())) }) @@ -399,7 +399,7 @@ var _ = Describe("Bootstrap", Label("bootstrap"), func() { _, err = t.DialContext(ctx, "ip", "abc:123") - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(err.Error()).Should(ContainSubstring("no such host")) }) }) diff --git a/resolver/client_names_resolver_test.go b/resolver/client_names_resolver_test.go index 2b700439..dd4748a0 100644 --- a/resolver/client_names_resolver_test.go +++ b/resolver/client_names_resolver_test.go @@ -377,7 +377,7 @@ var _ = Describe("ClientResolver", Label("clientNamesResolver"), func() { Upstream: config.Upstream{Host: "example.com"}, }, upstreamsCfg, b) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(r).Should(BeNil()) }) }) diff --git a/resolver/conditional_upstream_resolver_test.go b/resolver/conditional_upstream_resolver_test.go index df0f2aee..2780f02d 100644 --- a/resolver/conditional_upstream_resolver_test.go +++ b/resolver/conditional_upstream_resolver_test.go @@ -213,7 +213,7 @@ var _ = Describe("ConditionalUpstreamResolver", Label("conditionalResolver"), fu } r, err := NewConditionalUpstreamResolver(ctx, sutConfig, upstreamsCfg, b) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(r).Should(BeNil()) }) }) diff --git a/resolver/parallel_best_resolver_test.go b/resolver/parallel_best_resolver_test.go index 29ee05ca..e16233d5 100644 --- a/resolver/parallel_best_resolver_test.go +++ b/resolver/parallel_best_resolver_test.go @@ -323,7 +323,7 @@ var _ = Describe("ParallelBestResolver", Label("parallelBestResolver"), func() { group := config.NewUpstreamGroup("test", upstreamsCfg, []config.Upstream{{Host: "example.com"}}) r, err := NewParallelBestResolver(ctx, group, b) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) Expect(r).Should(BeNil()) }) }) diff --git a/resolver/resolver_test.go b/resolver/resolver_test.go index 5f8793e0..193a7600 100644 --- a/resolver/resolver_test.go +++ b/resolver/resolver_test.go @@ -61,7 +61,7 @@ var _ = Describe("Resolver", func() { ch := Chain(&CustomDNSResolver{}, &BlockingResolver{}) _, err := GetFromChainWithType[*FilteringResolver](ch) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) }) }) diff --git a/server/server_test.go b/server/server_test.go index f01733b8..8ce4a7df 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -592,7 +592,7 @@ var _ = Describe("Running DNS server", func() { _, err = NewServer(ctx, &cfg) - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) }) }) }) diff --git a/util/arpa_test.go b/util/arpa_test.go index 4489c2f6..d1085a79 100644 --- a/util/arpa_test.go +++ b/util/arpa_test.go @@ -17,37 +17,37 @@ var _ = Describe("ParseIPFromArpaAddr", func() { It("requires the arpa domain", func() { _, err := ParseIPFromArpaAddr("4.3.2.1.in-addr.arpa.fail.") - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) _, err = ParseIPFromArpaAddr("4.3.2.1.in-addr.fail.arpa.") - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) _, err = ParseIPFromArpaAddr("4.3.2.1.fail.in-addr.arpa.") - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) }) It("requires all ip parts to be decimal numbers", func() { _, err := ParseIPFromArpaAddr("a.3.2.1.in-addr.arpa.") - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) }) It("requires all parts to be present", func() { _, err := ParseIPFromArpaAddr("3.2.1.in-addr.arpa.") - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) }) It("requires all parts to be non empty", func() { _, err := ParseIPFromArpaAddr(".3.2.1.in-addr.arpa.") - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) _, err = ParseIPFromArpaAddr("4..2.1.in-addr.arpa.") - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) _, err = ParseIPFromArpaAddr("4.3..1.in-addr.arpa.") - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) _, err = ParseIPFromArpaAddr("4.3.2..in-addr.arpa.") - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) }) }) @@ -60,39 +60,39 @@ var _ = Describe("ParseIPFromArpaAddr", func() { It("requires the arpa domain", func() { _, err := ParseIPFromArpaAddr("1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.0.0.0.f.7.2.0.0.2.ip6.arpa.fail.") - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) _, err = ParseIPFromArpaAddr("1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.0.0.0.f.7.2.0.0.2.ip6.fail.arpa.") - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) _, err = ParseIPFromArpaAddr("1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.0.0.0.f.7.2.0.0.2.fail.ip6.arpa.") - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) }) It("requires all LSB parts to be hex numbers", func() { _, err := ParseIPFromArpaAddr("g.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.0.0.0.f.7.2.0.0.2.ip6.arpa.") - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) }) It("requires all MSB parts to be hex numbers", func() { _, err := ParseIPFromArpaAddr("1.g.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.0.0.0.f.7.2.0.0.2.ip6.arpa.") - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) }) It("requires all parts to be present", func() { _, err := ParseIPFromArpaAddr("1.0.0.0.0.0.0.0.0.0.0.0.0.g.0.0.0.0.1.0.0.0.0.0.f.7.2.0.0.2.ip6.arpa.") - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) }) It("requires all parts to non empty", func() { _, err := ParseIPFromArpaAddr(".0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.0.0.0.f.7.2.0.0.2.ip6.arpa.") - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) _, err = ParseIPFromArpaAddr("0.0.0.0.0.0.0.0.0.0.0.0.0.0.0..0.0.0.0.1.0.0.0.0.0.f.7.2.0.0.2.ip6.arpa.") - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) _, err = ParseIPFromArpaAddr("0.0.0.0.0.0.0.0.0.0.0.0.0.0.0..0.0.0.0.1.0.0.0.0.0.f.7.2.0.0..ip6.arpa.") - Expect(err).ShouldNot(Succeed()) + Expect(err).Should(HaveOccurred()) }) }) })