From 9d6791706d7df95d6b1f009190ba93556e2d3ec6 Mon Sep 17 00:00:00 2001 From: ramil Date: Mon, 19 Apr 2021 15:00:28 +0300 Subject: [PATCH] fix unit tests --- Makefile | 4 ++-- pkg/eth/api_test.go | 32 ++++++++++++++++---------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 552d9378..720a196e 100644 --- a/Makefile +++ b/Makefile @@ -61,7 +61,7 @@ test: | $(GINKGO) $(GOOSE) dropdb -h $(DATABASE_HOSTNAME) -p $(DATABASE_PORT) -U $(DATABASE_USER) --if-exists $(TEST_DB) createdb -h $(DATABASE_HOSTNAME) -p $(DATABASE_PORT) -U $(DATABASE_USER) $(TEST_DB) $(GOOSE) -dir db/migrations postgres "$(TEST_CONNECT_STRING)" up - $(GINKGO) -r --skipPackage=integration_test,integration + $(GINKGO) -r --skipPackage=test .PHONY: integrationtest integrationtest: | $(GINKGO) $(GOOSE) @@ -82,7 +82,7 @@ test_local: | $(GINKGO) $(GOOSE) $(GOOSE) -dir db/migrations postgres "$(TEST_CONNECT_STRING_LOCAL)" up $(GOOSE) -dir db/migrations postgres "$(TEST_CONNECT_STRING_LOCAL)" reset make migrate NAME=$(TEST_DB) - $(GINKGO) -r --skipPackage=integration_test,integration + $(GINKGO) -r --skipPackage=test .PHONY: integrationtest_local integrationtest_local: | $(GINKGO) $(GOOSE) diff --git a/pkg/eth/api_test.go b/pkg/eth/api_test.go index abf9266e..70e3c4c8 100644 --- a/pkg/eth/api_test.go +++ b/pkg/eth/api_test.go @@ -271,10 +271,10 @@ var _ = Describe("API", func() { Expect(val).To(Equal(block[key])) } }) - It("Throws an error if a block cannot be found", func() { - _, err := api.GetBlockByNumber(ctx, wrongNumber, false) - Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("sql: no rows in result set")) + It("Returns `nil` if a block cannot be found", func() { + block, err := api.GetBlockByNumber(ctx, wrongNumber, false) + Expect(err).ToNot(HaveOccurred()) + Expect(block).To(BeNil()) }) }) @@ -303,10 +303,10 @@ var _ = Describe("API", func() { Expect(val).To(Equal(block[key])) } }) - It("Throws an error if a block cannot be found", func() { - _, err := api.GetBlockByHash(ctx, randomHash, false) - Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("sql: no rows in result set")) + It("Returns `nil` if a block cannot be found", func() { + block, err := api.GetBlockByHash(ctx, randomHash, false) + Expect(err).ToNot(HaveOccurred()) + Expect(block).To(BeZero()) }) }) @@ -325,10 +325,10 @@ var _ = Describe("API", func() { Expect(err).ToNot(HaveOccurred()) Expect(uncle2).To(Equal(expectedUncle2)) }) - It("Throws an error if an block for blocknumber cannot be found", func() { - _, err := api.GetUncleByBlockNumberAndIndex(ctx, wrongNumber, 0) - Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("sql: no rows in result set")) + It("Returns `nil` if an block for blocknumber cannot be found", func() { + block, err := api.GetUncleByBlockNumberAndIndex(ctx, wrongNumber, 0) + Expect(err).ToNot(HaveOccurred()) + Expect(block).To(BeNil()) }) It("Returns `nil` if an uncle at the provided index does not exist for the block found for the provided block number", func() { uncle, err := api.GetUncleByBlockNumberAndIndex(ctx, number, 2) @@ -346,10 +346,10 @@ var _ = Describe("API", func() { Expect(err).ToNot(HaveOccurred()) Expect(uncle2).To(Equal(expectedUncle2)) }) - It("Throws an error if an block for blockhash cannot be found", func() { - _, err := api.GetUncleByBlockHashAndIndex(ctx, randomHash, 0) - Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("sql: no rows in result set")) + It("Returns `nil` if a block for blockhash cannot be found", func() { + block, err := api.GetUncleByBlockHashAndIndex(ctx, randomHash, 0) + Expect(err).ToNot(HaveOccurred()) + Expect(block).To(BeNil()) }) It("Returns `nil` if an uncle at the provided index does not exist for the block with the provided hash", func() { uncle, err := api.GetUncleByBlockHashAndIndex(ctx, blockHash, 2)