Skip to content

chore(helm): add unit tests for helm chart #6557

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

Merged
merged 20 commits into from
Mar 13, 2023
Merged

chore(helm): add unit tests for helm chart #6557

merged 20 commits into from
Mar 13, 2023

Conversation

johnstcn
Copy link
Member

@johnstcn johnstcn commented Mar 10, 2023

This PR adds a minimum set of Helm tests for the Helm chart.
It's heavily based on the approach in enterprise-helm, but uses a golden-files-based approach instead.
It also runs helm template directly instead of importing the entire Kubernetes API.

Golden files can be updated by running go test ./helm/tests -update or by running make update-golden-files.

Fixes #6552

@johnstcn johnstcn self-assigned this Mar 10, 2023
@kylecarbs
Copy link
Member

Excited for this!

@johnstcn johnstcn marked this pull request as ready for review March 10, 2023 17:35
@johnstcn johnstcn requested review from a team, sreya and kylecarbs and removed request for a team March 10, 2023 17:35
@deansheather
Copy link
Member

NOTE: The unfortunate part of this is that if you import helm, you also need to import the kitchen sink that is the Kubernetes API. These are only imported in test files however and should not inflate the coder binary we ship.

You should try a nested go.mod file so any packages that import coder don't suffer.

}

// Values is the top-level values struct for the Coder chart.
type Values struct {
Copy link
Member

Choose a reason for hiding this comment

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

Instead of having to maintain this type like we did in v1 (and forgot to do many times) can we just use map[string]any as the values type for test cases instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Decided to go one level further and just run helm template instead; it's conceptually much simpler and removes the extra k8s API deps.

Copy link
Member

@deansheather deansheather left a comment

Choose a reason for hiding this comment

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

Looks great!

@johnstcn johnstcn merged commit 9b2abf0 into main Mar 13, 2023
@johnstcn johnstcn deleted the cj/helm-tests branch March 13, 2023 13:48
@github-actions github-actions bot locked and limited conversation to collaborators Mar 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add unit tests for Helm chart
3 participants