Skip to content

Commit

Permalink
style(tests): Should(Not(x)) -> ShouldNot(x)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThinkChaos committed Dec 1, 2023
1 parent b1cd255 commit 3216802
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 29 deletions.
12 changes: 6 additions & 6 deletions cache/expirationcache/expiration_cache_test.go
Expand Up @@ -123,25 +123,25 @@ var _ = Describe("Expiration cache", func() {
Expect(val).Should(BeNil())

Expect(onCacheMissChannel).Should(Receive(Equal("notExists")))
Expect(onCacheHitChannel).Should(Not(Receive()))
Expect(onAfterPutChannel).Should(Not(Receive()))
Expect(onCacheHitChannel).ShouldNot(Receive())
Expect(onAfterPutChannel).ShouldNot(Receive())
})

By("Put new cache entry", func() {
v1 := "v1"
cache.Put("key1", &v1, time.Second)
Expect(onCacheMissChannel).Should(Not(Receive()))
Expect(onCacheMissChannel).Should(Not(Receive()))
Expect(onCacheMissChannel).ShouldNot(Receive())
Expect(onCacheMissChannel).ShouldNot(Receive())
Expect(onAfterPutChannel).Should(Receive(Equal(1)))
})

By("Get existing value", func() {
val, _ := cache.Get("key1")
Expect(val).Should(HaveValue(Equal("v1")))

Expect(onCacheMissChannel).Should(Not(Receive()))
Expect(onCacheMissChannel).ShouldNot(Receive())
Expect(onCacheHitChannel).Should(Receive(Equal("key1")))
Expect(onAfterPutChannel).Should(Not(Receive()))
Expect(onAfterPutChannel).ShouldNot(Receive())
})
})
})
Expand Down
12 changes: 6 additions & 6 deletions cache/expirationcache/prefetching_cache_test.go
Expand Up @@ -155,17 +155,17 @@ var _ = Describe("Prefetching expiration cache", func() {
By("put a value", func() {
v := "v1"
cache.Put("key1", &v, 50*time.Millisecond)
Expect(onPrefetchAfterPutChannel).Should(Not(Receive()))
Expect(onPrefetchEntryReloaded).Should(Not(Receive()))
Expect(onnPrefetchCacheHit).Should(Not(Receive()))
Expect(onPrefetchAfterPutChannel).ShouldNot(Receive())
Expect(onPrefetchEntryReloaded).ShouldNot(Receive())
Expect(onnPrefetchCacheHit).ShouldNot(Receive())
})
By("get a value 3 times to trigger prefetching", func() {
// first get
cache.Get("key1")

Expect(onPrefetchAfterPutChannel).Should(Receive(Equal(1)))
Expect(onnPrefetchCacheHit).Should(Not(Receive()))
Expect(onPrefetchEntryReloaded).Should(Not(Receive()))
Expect(onnPrefetchCacheHit).ShouldNot(Receive())
Expect(onPrefetchEntryReloaded).ShouldNot(Receive())

// secont get
val, _ := cache.Get("key1")
Expand All @@ -176,7 +176,7 @@ var _ = Describe("Prefetching expiration cache", func() {

// reload was executed
Eventually(onPrefetchEntryReloaded).Should(Receive(Equal("key1")))
Expect(onnPrefetchCacheHit).Should(Not(Receive()))
Expect(onnPrefetchCacheHit).ShouldNot(Receive())
// has new value
Eventually(func(g Gomega) {
val, _ := cache.Get("key1")
Expand Down
4 changes: 2 additions & 2 deletions config/config_test.go
Expand Up @@ -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).Should(Not(Succeed()))
Expect(err).ShouldNot(Succeed())
})
})
When("Multiple config files are used", func() {
Expand Down Expand Up @@ -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).Should(Not(Succeed()))
Expect(err).ShouldNot(Succeed())
})
})
When("config file is malformed", func() {
Expand Down
4 changes: 2 additions & 2 deletions e2e/basic_test.go
Expand Up @@ -181,8 +181,8 @@ var _ = Describe("Basic functional tests", func() {
HaveTTL(BeNumerically("<=", 123)),
))

Expect(getContainerLogs(ctx, blocky)).Should(Not(ContainElement(ContainSubstring("google.com"))))
Expect(getContainerLogs(ctx, blocky)).Should(Not(ContainElement(ContainSubstring("1.2.3.4"))))
Expect(getContainerLogs(ctx, blocky)).ShouldNot(ContainElement(ContainSubstring("google.com")))
Expect(getContainerLogs(ctx, blocky)).ShouldNot(ContainElement(ContainSubstring("1.2.3.4")))
})
})
})
Expand Down
12 changes: 6 additions & 6 deletions e2e/querylog_test.go
Expand Up @@ -59,7 +59,7 @@ var _ = Describe("Query logs functional tests", func() {

// database might be slow on first start, retry here if necessary
Eventually(gorm.Open, "10s", "1s").
WithArguments(mysqlDriver.Open(connectionString), &gorm.Config{}).Should(Not(BeNil()))
WithArguments(mysqlDriver.Open(connectionString), &gorm.Config{}).ShouldNot(BeNil())

db, err = gorm.Open(mysqlDriver.Open(connectionString), &gorm.Config{})
Expect(err).Should(Succeed())
Expand All @@ -70,9 +70,9 @@ var _ = Describe("Query logs functional tests", func() {
It("Should store query log in the mariaDB database", func(ctx context.Context) {
By("Performing 2 queries", func() {
Expect(doDNSRequest(ctx, blocky,
util.NewMsgWithQuestion("google.de.", dns.Type(dns.TypeA)))).Should(Not(BeNil()))
util.NewMsgWithQuestion("google.de.", dns.Type(dns.TypeA)))).ShouldNot(BeNil())
Expect(doDNSRequest(ctx, blocky,
util.NewMsgWithQuestion("unknown.domain.", dns.Type(dns.TypeA)))).Should(Not(BeNil()))
util.NewMsgWithQuestion("unknown.domain.", dns.Type(dns.TypeA)))).ShouldNot(BeNil())
})

By("check entries count asynchronously, since blocky flushes log entries in bulk", func() {
Expand Down Expand Up @@ -136,7 +136,7 @@ var _ = Describe("Query logs functional tests", func() {

// database might be slow on first start, retry here if necessary
Eventually(gorm.Open, "10s", "1s").
WithArguments(postgresDriver.Open(connectionString), &gorm.Config{}).Should(Not(BeNil()))
WithArguments(postgresDriver.Open(connectionString), &gorm.Config{}).ShouldNot(BeNil())

db, err = gorm.Open(postgresDriver.Open(connectionString), &gorm.Config{})
Expect(err).Should(Succeed())
Expand All @@ -147,8 +147,8 @@ var _ = Describe("Query logs functional tests", func() {
msg := util.NewMsgWithQuestion("google.de.", dns.Type(dns.TypeA))
It("Should store query log in the postgres database", func(ctx context.Context) {
By("Performing 2 queries", func() {
Expect(doDNSRequest(ctx, blocky, msg)).Should(Not(BeNil()))
Expect(doDNSRequest(ctx, blocky, msg)).Should(Not(BeNil()))
Expect(doDNSRequest(ctx, blocky, msg)).ShouldNot(BeNil())
Expect(doDNSRequest(ctx, blocky, msg)).ShouldNot(BeNil())
})

By("check entries count asynchronously, since blocky flushes log entries in bulk", func() {
Expand Down
4 changes: 2 additions & 2 deletions lists/downloader_test.go
Expand Up @@ -85,7 +85,7 @@ var _ = Describe("Downloader", func() {
reader, err := sut.DownloadFile(ctx, server.URL)

Expect(err).Should(Succeed())
Expect(reader).Should(Not(BeNil()))
Expect(reader).ShouldNot(BeNil())
DeferCleanup(reader.Close)
buf := new(strings.Builder)
_, err = io.Copy(buf, reader)
Expand Down Expand Up @@ -153,7 +153,7 @@ var _ = Describe("Downloader", func() {
It("Should perform a retry and return file content", func(ctx context.Context) {
reader, err := sut.DownloadFile(ctx, server.URL)
Expect(err).Should(Succeed())
Expect(reader).Should(Not(BeNil()))
Expect(reader).ShouldNot(BeNil())
DeferCleanup(reader.Close)

buf := new(strings.Builder)
Expand Down
2 changes: 1 addition & 1 deletion resolver/parallel_best_resolver_test.go
Expand Up @@ -120,7 +120,7 @@ var _ = Describe("ParallelBestResolver", Label("parallelBestResolver"), func() {
sutVerify = noVerifyUpstreams
})
It("should start", func() {
Expect(err).Should(Not(HaveOccurred()))
Expect(err).ShouldNot(HaveOccurred())
})
})
})
Expand Down
2 changes: 1 addition & 1 deletion resolver/query_logging_resolver_test.go
Expand Up @@ -148,7 +148,7 @@ var _ = Describe("QueryLoggingResolver", func() {
fmt.Sprintf("%s_client1.log", time.Now().Format("2006-01-02"))))

g.Expect(err).Should(Succeed())
g.Expect(csvLines).Should(Not(BeEmpty()))
g.Expect(csvLines).ShouldNot(BeEmpty())
g.Expect(csvLines[0][1]).Should(Equal("192.168.178.25"))
g.Expect(csvLines[0][2]).Should(Equal("client1"))
g.Expect(csvLines[0][4]).Should(Equal("reason"))
Expand Down
2 changes: 1 addition & 1 deletion resolver/resolver_test.go
Expand Up @@ -61,7 +61,7 @@ var _ = Describe("Resolver", func() {
ch := Chain(&CustomDNSResolver{}, &BlockingResolver{})
_, err := GetFromChainWithType[*FilteringResolver](ch)

Expect(err).Should(Not(Succeed()))
Expect(err).ShouldNot(Succeed())
})
})

Expand Down
4 changes: 2 additions & 2 deletions resolver/strict_resolver_test.go
Expand Up @@ -112,7 +112,7 @@ var _ = Describe("StrictResolver", Label("strictResolver"), func() {
})

It("should start normally", func() {
Expect(err).Should(Not(HaveOccurred()))
Expect(err).ShouldNot(HaveOccurred())
})
})

Expand All @@ -138,7 +138,7 @@ var _ = Describe("StrictResolver", Label("strictResolver"), func() {
sutVerify = noVerifyUpstreams
})
It("should start", func() {
Expect(err).Should(Not(HaveOccurred()))
Expect(err).ShouldNot(HaveOccurred())
})
})
})
Expand Down

0 comments on commit 3216802

Please sign in to comment.