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

Unit tests for contour k8sd feature #705

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

maci3jka
Copy link
Contributor

The unit tests for the contour feature are lacking this pr proves test coverage from 0% files, 0% statements to 100% files, 84.3% statements for github.com/canonical/k8s/pkg/k8sd/features/contour package.

@maci3jka
Copy link
Contributor Author

adresses also KU-1516

Copy link
Contributor

@HomayoonAlimohammadi HomayoonAlimohammadi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @maci3jka! LGTM, great stuff!

Copy link
Member

@berkayoz berkayoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Left some comments

g.Expect(err.Error()).To(ContainSubstring(applyErr.Error()))
g.Expect(status.Enabled).To(BeFalse())
g.Expect(status.Version).To(Equal(contour.ContourGatewayProvisionerContourImageTag))
g.Expect(status.Message).To(ContainSubstring("Failed to delete Contour Gateway"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
g.Expect(status.Message).To(ContainSubstring("Failed to delete Contour Gateway"))
g.Expect(status.Message).To(Equal(fmt.Sprintf(gatewayDeleteFailedMsgTmpl, err)))

I believe we can just use the err returned from ApplyGateway to construct the entire status.Message.

projectcontour := values["projectcontour"].(map[string]any)["image"].(map[string]any)
g.Expect(projectcontour["repository"]).To(Equal(contour.ContourGatewayProvisionerContourImageRepo))
g.Expect(projectcontour["tag"]).To(Equal(contour.ContourGatewayProvisionerContourImageTag))
envoy := values["envoyproxy"].(map[string]any)["image"].(map[string]any)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
envoy := values["envoyproxy"].(map[string]any)["image"].(map[string]any)
envoyImage := values["envoyproxy"].(map[string]any)["image"].(map[string]any)

Also we should check for envoyproxy and image to exist first, otherwise we'll do a nil cast/reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants