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

chore: cleanup errchecking in tests #3040

Merged
merged 37 commits into from
Sep 30, 2024
Merged

chore: cleanup errchecking in tests #3040

merged 37 commits into from
Sep 30, 2024

Conversation

mkcp
Copy link
Contributor

@mkcp mkcp commented Sep 26, 2024

Description

This PR is split out from #2993 to only fix ignored errors in tests.

Related Issue

Fixes #2949
Relates to #2993, #2953

Checklist before merging

@mkcp mkcp self-assigned this Sep 26, 2024
@mkcp mkcp requested review from a team as code owners September 26, 2024 17:08
Copy link

netlify bot commented Sep 26, 2024

Deploy Preview for zarf-docs canceled.

Name Link
🔨 Latest commit e23dd79
🔍 Latest deploy log https://app.netlify.com/sites/zarf-docs/deploys/66faf0ad19707100088cfceb

mkcp added 26 commits September 26, 2024 10:26
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
… to nolint ignore them

Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
…anic

Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
…gnore it

Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
…r before loop

Signed-off-by: Kit Patella <kit@defenseunicorns.com>
…caller

Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
@mkcp mkcp force-pushed the 2949-test-errchecking branch from a8e5de9 to 20241aa Compare September 26, 2024 17:26
Copy link

codecov bot commented Sep 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Copy link
Contributor

@AustinAbro321 AustinAbro321 left a comment

Choose a reason for hiding this comment

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

Only one comment, but it applies to most of the defers that got deleted. I think we should keep the defers, and check errors within them otherwise during when a test fails before the cleanup step there will be no cleanup.

src/test/e2e/14_oci_compose_test.go Outdated Show resolved Hide resolved
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
@mkcp
Copy link
Contributor Author

mkcp commented Sep 26, 2024

@AustinAbro321 Defers should be fixed in latest, also added some todos for when we swap over to the linter in main

schristoff
schristoff previously approved these changes Sep 27, 2024
@@ -139,30 +143,37 @@ func configFileDefaultTests(t *testing.T) {
}

// Test remaining default initializers
t.Setenv("ZARF_CONFIG", filepath.Join("src", "test", "zarf-config-test.toml"))
defer os.Unsetenv("ZARF_CONFIG")
envKey := "ZARF_CONFIG"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Could just set as const mayb?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

def, opted to keep it consistent but const was preferred

Copy link
Contributor

@AustinAbro321 AustinAbro321 left a comment

Choose a reason for hiding this comment

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

A few more comments, but it's very close. Nice work! I've learned a lot about defer while doing this reviews

src/test/common.go Show resolved Hide resolved
src/test/e2e/21_connect_creds_test.go Outdated Show resolved Hide resolved
src/test/e2e/14_oci_compose_test.go Show resolved Hide resolved
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
@mkcp
Copy link
Contributor Author

mkcp commented Sep 30, 2024

A few more comments, but it's very close. Nice work! I've learned a lot about defer while doing this reviews

Should all be reserved (cc @schristoff) and yeah 100% here too. I ended up trying a bunch of different error handling patterns, from manual orders to the named err + join, and definitely added a few tricks to the toolbox. named err + join is probably the closest thing we have in Go to a Finally block.

Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
@mkcp mkcp added this pull request to the merge queue Sep 30, 2024
Merged via the queue into main with commit 59b373a Sep 30, 2024
30 checks passed
@mkcp mkcp deleted the 2949-test-errchecking branch September 30, 2024 19:30
ittacco pushed a commit to ittacco/zarf that referenced this pull request Nov 9, 2024
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: ittacco <lorenzo.tacconi1967@gmail.com>
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.

Enable linting ignored
3 participants