mirror of https://github.com/0xERR0R/blocky.git
style(tests): `Should(Not(x))` -> `ShouldNot(x)`
This commit is contained in:
parent
b1cd255799
commit
321680250a
|
@ -123,15 +123,15 @@ 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)))
|
||||
})
|
||||
|
||||
|
@ -139,9 +139,9 @@ var _ = Describe("Expiration cache", 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())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -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")
|
||||
|
@ -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")
|
||||
|
|
|
@ -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() {
|
||||
|
@ -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() {
|
||||
|
|
|
@ -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")))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -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())
|
||||
|
@ -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() {
|
||||
|
@ -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())
|
||||
|
@ -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() {
|
||||
|
|
|
@ -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)
|
||||
|
@ -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)
|
||||
|
|
|
@ -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())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -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"))
|
||||
|
|
|
@ -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())
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ var _ = Describe("StrictResolver", Label("strictResolver"), func() {
|
|||
})
|
||||
|
||||
It("should start normally", func() {
|
||||
Expect(err).Should(Not(HaveOccurred()))
|
||||
Expect(err).ShouldNot(HaveOccurred())
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -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())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue