forked from cerc-io/ipld-eth-server
fix unit tests
This commit is contained in:
parent
50d53535bb
commit
9d6791706d
4
Makefile
4
Makefile
@ -61,7 +61,7 @@ test: | $(GINKGO) $(GOOSE)
|
|||||||
dropdb -h $(DATABASE_HOSTNAME) -p $(DATABASE_PORT) -U $(DATABASE_USER) --if-exists $(TEST_DB)
|
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)
|
createdb -h $(DATABASE_HOSTNAME) -p $(DATABASE_PORT) -U $(DATABASE_USER) $(TEST_DB)
|
||||||
$(GOOSE) -dir db/migrations postgres "$(TEST_CONNECT_STRING)" up
|
$(GOOSE) -dir db/migrations postgres "$(TEST_CONNECT_STRING)" up
|
||||||
$(GINKGO) -r --skipPackage=integration_test,integration
|
$(GINKGO) -r --skipPackage=test
|
||||||
|
|
||||||
.PHONY: integrationtest
|
.PHONY: integrationtest
|
||||||
integrationtest: | $(GINKGO) $(GOOSE)
|
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)" up
|
||||||
$(GOOSE) -dir db/migrations postgres "$(TEST_CONNECT_STRING_LOCAL)" reset
|
$(GOOSE) -dir db/migrations postgres "$(TEST_CONNECT_STRING_LOCAL)" reset
|
||||||
make migrate NAME=$(TEST_DB)
|
make migrate NAME=$(TEST_DB)
|
||||||
$(GINKGO) -r --skipPackage=integration_test,integration
|
$(GINKGO) -r --skipPackage=test
|
||||||
|
|
||||||
.PHONY: integrationtest_local
|
.PHONY: integrationtest_local
|
||||||
integrationtest_local: | $(GINKGO) $(GOOSE)
|
integrationtest_local: | $(GINKGO) $(GOOSE)
|
||||||
|
@ -271,10 +271,10 @@ var _ = Describe("API", func() {
|
|||||||
Expect(val).To(Equal(block[key]))
|
Expect(val).To(Equal(block[key]))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
It("Throws an error if a block cannot be found", func() {
|
It("Returns `nil` if a block cannot be found", func() {
|
||||||
_, err := api.GetBlockByNumber(ctx, wrongNumber, false)
|
block, err := api.GetBlockByNumber(ctx, wrongNumber, false)
|
||||||
Expect(err).To(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(err.Error()).To(ContainSubstring("sql: no rows in result set"))
|
Expect(block).To(BeNil())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -303,10 +303,10 @@ var _ = Describe("API", func() {
|
|||||||
Expect(val).To(Equal(block[key]))
|
Expect(val).To(Equal(block[key]))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
It("Throws an error if a block cannot be found", func() {
|
It("Returns `nil` if a block cannot be found", func() {
|
||||||
_, err := api.GetBlockByHash(ctx, randomHash, false)
|
block, err := api.GetBlockByHash(ctx, randomHash, false)
|
||||||
Expect(err).To(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(err.Error()).To(ContainSubstring("sql: no rows in result set"))
|
Expect(block).To(BeZero())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -325,10 +325,10 @@ var _ = Describe("API", func() {
|
|||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(uncle2).To(Equal(expectedUncle2))
|
Expect(uncle2).To(Equal(expectedUncle2))
|
||||||
})
|
})
|
||||||
It("Throws an error if an block for blocknumber cannot be found", func() {
|
It("Returns `nil` if an block for blocknumber cannot be found", func() {
|
||||||
_, err := api.GetUncleByBlockNumberAndIndex(ctx, wrongNumber, 0)
|
block, err := api.GetUncleByBlockNumberAndIndex(ctx, wrongNumber, 0)
|
||||||
Expect(err).To(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(err.Error()).To(ContainSubstring("sql: no rows in result set"))
|
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() {
|
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)
|
uncle, err := api.GetUncleByBlockNumberAndIndex(ctx, number, 2)
|
||||||
@ -346,10 +346,10 @@ var _ = Describe("API", func() {
|
|||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(uncle2).To(Equal(expectedUncle2))
|
Expect(uncle2).To(Equal(expectedUncle2))
|
||||||
})
|
})
|
||||||
It("Throws an error if an block for blockhash cannot be found", func() {
|
It("Returns `nil` if a block for blockhash cannot be found", func() {
|
||||||
_, err := api.GetUncleByBlockHashAndIndex(ctx, randomHash, 0)
|
block, err := api.GetUncleByBlockHashAndIndex(ctx, randomHash, 0)
|
||||||
Expect(err).To(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(err.Error()).To(ContainSubstring("sql: no rows in result set"))
|
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() {
|
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)
|
uncle, err := api.GetUncleByBlockHashAndIndex(ctx, blockHash, 2)
|
||||||
|
Loading…
Reference in New Issue
Block a user