Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase the test coverage from 20% to 49% #461

Merged
merged 3 commits into from
May 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,9 @@ catalog-build: opm ## Build a catalog image.
.PHONY: catalog-push
catalog-push: ## Push a catalog image.
$(MAKE) docker-push IMG=$(CATALOG_IMG)

# Test coverage
.PHONY: coverage
coverage: ## Generate test coverage report
go test ./... -coverprofile cover.out
go tool cover -html=cover.out -o cover.html
7 changes: 7 additions & 0 deletions api/v1alpha1/broker_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ var _ = Describe("The test cases for customize resource: Broker", func() {
Expect(broker2.Spec.Size).Should(Equal(int32(2)))
})

// check broker list
It("should list the Broker object successfully", func() {
brokerList := &BrokerList{}
Expect(fakeClient.List(ctx, brokerList)).Should(Succeed())
Expect(len(brokerList.Items)).Should(Equal(1))
})

It("should delete the Broker object successfully", func() {
Expect(fakeClient.Delete(ctx, broker)).Should(Succeed())
})
Expand Down
13 changes: 13 additions & 0 deletions api/v1alpha1/meshsync_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,21 @@ var _ = Describe("The test case for the meshsync CRDs", func() {
err := fakeClient.Status().Update(context, meshSync, &client.UpdateOptions{FieldManager: FileManager})

Expect(err).NotTo(HaveOccurred())
Expect(meshSync.Status.PublishingTo == PublishingTo).Should(BeTrue())
})

It("The meshsyncList CRDs should be support by the kubernetes server", func() {
By("Confirm the meshsync CRDs support by the kubernetes server")
meshSyncList := &MeshSyncList{}
err := fakeClient.List(context, meshSyncList, &client.ListOptions{})
Expect(err).NotTo(HaveOccurred())
Expect(len(meshSyncList.Items) > 0).Should(BeTrue())
})

})

// Test coverage for delete the meshsync CRDs
Context("The test coverage for delete the meshsync CRDs", func() {
It("The meshsync CRDs remove the resources ", func() {
By("Delete the meshsync CRDs")
err := fakeClient.Delete(context, meshSync)
Expand Down