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

Add tests for DeleteRelease #1438

Merged
merged 2 commits into from
Jan 13, 2020

Conversation

latiif
Copy link
Contributor

@latiif latiif commented Jan 12, 2020

Description of the change

Tests new functionality introduced by #1420

Benefits

  • Adds test for DeleteRelease in /pkg/agent
  • Adds action="delete" tests for /kubeops/handler

Possible drawbacks

Skip tests blocked by memory driver bug

Applicable issues

Additional information

Contains a TODO in /cmd/kubeops/internal/handler/handler_test.go with instructions on what to do when the memory driver bug is fixed.

Add SKIP switch to tests in /kubeops/internal/handler

Signed-off-by: Latiif <abdullatif.alshriaf@combitech.se>
}

for _, test := range tests {
t.Run(test.Description, func(t *testing.T) {
// TODO Remove this `if` statement after the memory driver bug is fixed
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @latiif . Can you reference the actual Issue/PR (PR in this case) to make it easier to audit later? Thanks. (both in this PR and the previous test one)

makeReleases(t, cfg, tc.releases)
err := DeleteRelease(cfg, tc.releaseToDelete, true)
t.Logf("error: %v", err)
if isOk := err != nil == tc.shouldFail; !isOk {
Copy link
Contributor

Choose a reason for hiding this comment

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

This might be easier to read as:

if didFail := err != nil; didFail != tc.shouldFail {

}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This reads easier 👍

@@ -140,6 +214,8 @@ func TestActions(t *testing.T) {
switch test.Action {
case "create":
CreateRelease(*cfg, response, req, test.Params)
case "delete":
DeleteRelease(*cfg, response, req, test.Params)
Copy link
Contributor

Choose a reason for hiding this comment

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

See what you think, but in #1439 I've used a separate test case for Rollback, rather than adding to this one. As mentioned there, I know it's probably just following the precedent from tiller-proxy, but it means tests for the individual handlers can't be focused. For example, here we've had to add a t.SkipNow() which is only relevant for a certain Delete action. Anyway, happy for this to land as is, just pointing out in case you choose to separate them. I can re-base my diff once yours lands.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Smaller functions are always better.
To avoid overhead complications with multiple test PR's coming in right now, and the eventuality of merge conflicts. I plan to postpone splitting up the TestActions function to smaller ones, once the test PR's have landed. If that's okay with you.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, that's fine. Let's land this one (and your other one), then tomorrow I'll rebase my Rollback one with the separate test and we can go from there.

Signed-off-by: Latiif <abdullatif.alshriaf@combitech.se>
@absoludity absoludity merged commit 8bb060e into vmware-tanzu:master Jan 13, 2020
@latiif latiif deleted the test-helm3-delete-release branch January 13, 2020 12:22
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.

2 participants