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

feat: add unit tests for Helm chart #158

Merged
merged 1 commit into from
Nov 2, 2021

Conversation

jawnsy
Copy link
Contributor

@jawnsy jawnsy commented Nov 2, 2021

Very rough first pass, mostly a proof-of-concept. The tests aren't complete, and not part of CI yet, but the goal is to show what writing them could look like.

@shortcut-integration
Copy link

This pull request has been linked to Shortcut Story #15699: Automated unit tests for Helm package.

@jawnsy jawnsy self-assigned this Nov 2, 2021
@jawnsy jawnsy requested review from Emyrk and johnstcn November 2, 2021 01:34
Copy link
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

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

I really like the shape of this. Being able to just take a values.yaml, render the Helm chart, and make assertions about the output is really powerful!

// CoderValues is a typed Go representation of Coder's values file,
// suitable for writing tests. This provides code completion for Go
// tests.
type CoderValues struct {
Copy link
Member

Choose a reason for hiding this comment

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

Keeping this in sync manually is going to be an issue down the line.
Could we generate this automatically from values.yaml?

Aside: is there any decent tool for doing this directly? I found yaml2go but it appears to not be maintained. We could also go the route of YAML -> JSON -> Go, for which there is a slightly more up to date tool. If all else fails, I suppose there's Swagger.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I discussed this with @Emyrk, there's a way you can define a JSON Schema to validate the values, and we could generate both the values.yaml and these structs from that. But in the interest of an initial implementation, I left taht out for now :)

Copy link
Member

Choose a reason for hiding this comment

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

Nice :-) I think this will really help!

@jawnsy jawnsy merged commit b9ac27f into main Nov 2, 2021
@jawnsy jawnsy deleted the jawnsy/sc-15699/add-helm-unit-tests branch November 2, 2021 14:29
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.

None yet

2 participants