fix unit tests

This commit is contained in:
ramil 2021-04-19 15:00:28 +03:00
parent 50d53535bb
commit 9d6791706d
2 changed files with 18 additions and 18 deletions

View File

@ -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)

View File

@ -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)