From 6e15d5351b96f0d2edf17bd48067cb58d864cf42 Mon Sep 17 00:00:00 2001
From: Kit Patella <kit@defenseunicorns.com>
Date: Mon, 30 Sep 2024 12:07:13 -0700
Subject: [PATCH] chore: cleanup errchecking in tests (#3040)

Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: ittacco <lorenzo.tacconi1967@gmail.com>
---
 src/test/common.go                            | 18 +++--
 src/test/e2e/00_use_cli_test.go               | 13 +--
 src/test/e2e/01_component_choice_test.go      |  2 +-
 src/test/e2e/02_component_actions_test.go     | 10 +--
 src/test/e2e/03_deprecations_test.go          | 12 +--
 src/test/e2e/04_create_templating_test.go     |  2 +-
 src/test/e2e/05_tarball_test.go               |  8 +-
 src/test/e2e/06_create_sbom_test.go           |  4 +-
 src/test/e2e/07_create_git_test.go            |  2 +-
 src/test/e2e/08_create_differential_test.go   |  4 +-
 src/test/e2e/11_oci_pull_inspect_test.go      |  2 +-
 src/test/e2e/12_lint_test.go                  |  6 +-
 src/test/e2e/14_oci_compose_test.go           | 79 +++++++++++--------
 src/test/e2e/20_zarf_init_test.go             |  6 +-
 src/test/e2e/21_connect_creds_test.go         |  4 +-
 src/test/e2e/22_git_and_gitops_test.go        |  2 +-
 src/test/e2e/24_variables_test.go             | 10 ++-
 src/test/e2e/25_helm_test.go                  | 10 ++-
 src/test/e2e/28_wait_test.go                  |  2 +-
 src/test/e2e/29_config_file_test.go           | 39 +++++----
 .../e2e/30_component_action_cluster_test.go   |  2 +-
 .../e2e/31_checksum_and_signature_test.go     |  2 +-
 src/test/e2e/32_component_webhooks_test.go    |  2 +-
 src/test/e2e/33_manifest_with_symlink_test.go |  4 +-
 src/test/e2e/34_custom_init_package_test.go   |  2 +-
 src/test/e2e/50_oci_publish_deploy_test.go    |  4 +-
 src/test/external/common.go                   |  3 +-
 src/test/external/ext_in_cluster_test.go      |  6 +-
 src/test/external/ext_out_cluster_test.go     | 40 ++++++----
 src/test/nightly/ecr_publish_test.go          |  2 +-
 src/test/upgrade/previously_built_test.go     | 30 ++++---
 31 files changed, 198 insertions(+), 134 deletions(-)

diff --git a/src/test/common.go b/src/test/common.go
index 746600feb1..4201fea6b9 100644
--- a/src/test/common.go
+++ b/src/test/common.go
@@ -6,6 +6,7 @@ package test
 
 import (
 	"bufio"
+	"errors"
 	"fmt"
 	"os"
 	"regexp"
@@ -53,13 +54,16 @@ func GetCLIName() string {
 }
 
 // Zarf executes a Zarf command.
-func (e2e *ZarfE2ETest) Zarf(t *testing.T, args ...string) (string, string, error) {
+func (e2e *ZarfE2ETest) Zarf(t *testing.T, args ...string) (_ string, _ string, err error) {
 	if !slices.Contains(args, "--tmpdir") && !slices.Contains(args, "tools") {
 		tmpdir, err := os.MkdirTemp("", "zarf-")
 		if err != nil {
 			return "", "", err
 		}
-		defer os.RemoveAll(tmpdir)
+		defer func(path string) {
+			errRemove := os.RemoveAll(path)
+			err = errors.Join(err, errRemove)
+		}(tmpdir)
 		args = append(args, "--tmpdir", tmpdir)
 	}
 	if !slices.Contains(args, "--zarf-cache") && !slices.Contains(args, "tools") && os.Getenv("CI") == "true" {
@@ -74,7 +78,10 @@ func (e2e *ZarfE2ETest) Zarf(t *testing.T, args ...string) (string, string, erro
 			return "", "", err
 		}
 		args = append(args, "--zarf-cache", cacheDir)
-		defer os.RemoveAll(cacheDir)
+		defer func(path string) {
+			errRemove := os.RemoveAll(path)
+			err = errors.Join(err, errRemove)
+		}(cacheDir)
 	}
 	return exec.CmdWithTesting(t, exec.PrintCfg(), e2e.ZarfBinPath, args...)
 }
@@ -87,9 +94,10 @@ func (e2e *ZarfE2ETest) Kubectl(t *testing.T, args ...string) (string, string, e
 }
 
 // CleanFiles removes files and directories that have been created during the test.
-func (e2e *ZarfE2ETest) CleanFiles(files ...string) {
+func (e2e *ZarfE2ETest) CleanFiles(t *testing.T, files ...string) {
 	for _, file := range files {
-		_ = os.RemoveAll(file)
+		err := os.RemoveAll(file)
+		require.NoError(t, err)
 	}
 }
 
diff --git a/src/test/e2e/00_use_cli_test.go b/src/test/e2e/00_use_cli_test.go
index 366bacb7f9..e5bc25cb4d 100644
--- a/src/test/e2e/00_use_cli_test.go
+++ b/src/test/e2e/00_use_cli_test.go
@@ -27,9 +27,9 @@ func TestUseCLI(t *testing.T) {
 		expectedShasum := "61b50898f982d015ed87093ba822de0fe011cec6dd67db39f99d8c56391a6109\n"
 		shasumTestFilePath := "shasum-test-file"
 
-		e2e.CleanFiles(shasumTestFilePath)
+		e2e.CleanFiles(t, shasumTestFilePath)
 		t.Cleanup(func() {
-			e2e.CleanFiles(shasumTestFilePath)
+			e2e.CleanFiles(t, shasumTestFilePath)
 		})
 
 		err := os.WriteFile(shasumTestFilePath, []byte("random test data 🦄\n"), helpers.ReadWriteUser)
@@ -110,7 +110,8 @@ func TestUseCLI(t *testing.T) {
 	t.Run("changing log level", func(t *testing.T) {
 		t.Parallel()
 		// Test that changing the log level actually applies the requested level
-		_, stdErr, _ := e2e.Zarf(t, "internal", "crc32", "zarf", "--log-level=debug")
+		_, stdErr, err := e2e.Zarf(t, "internal", "crc32", "zarf", "--log-level=debug")
+		require.NoError(t, err)
 		expectedOutString := "Log level set to debug"
 		require.Contains(t, stdErr, expectedOutString, "The log level should be changed to 'debug'")
 	})
@@ -138,7 +139,7 @@ func TestUseCLI(t *testing.T) {
 		require.FileExists(t, "binaries/eksctl_Darwin_arm64")
 		require.FileExists(t, "binaries/eksctl_Linux_x86_64")
 
-		e2e.CleanFiles("binaries/eksctl_Darwin_x86_64", "binaries/eksctl_Darwin_arm64", "binaries/eksctl_Linux_x86_64", path, "eks.yaml")
+		e2e.CleanFiles(t, "binaries/eksctl_Darwin_x86_64", "binaries/eksctl_Darwin_arm64", "binaries/eksctl_Linux_x86_64", path, "eks.yaml")
 	})
 
 	t.Run("zarf package create with tmpdir and cache", func(t *testing.T) {
@@ -164,7 +165,7 @@ func TestUseCLI(t *testing.T) {
 			secondFile = "second-choice-file.txt"
 		)
 		t.Cleanup(func() {
-			e2e.CleanFiles(firstFile, secondFile)
+			e2e.CleanFiles(t, firstFile, secondFile)
 		})
 		path := fmt.Sprintf("build/zarf-package-component-choice-%s.tar.zst", e2e.Arch)
 		stdOut, stdErr, err := e2e.Zarf(t, "package", "deploy", path, "--tmpdir", tmpdir, "--log-level=debug", "--confirm")
@@ -197,7 +198,7 @@ func TestUseCLI(t *testing.T) {
 		tlsCert := "tls.crt"
 		tlsKey := "tls.key"
 		t.Cleanup(func() {
-			e2e.CleanFiles(tlsCA, tlsCert, tlsKey)
+			e2e.CleanFiles(t, tlsCA, tlsCert, tlsKey)
 		})
 		stdOut, stdErr, err := e2e.Zarf(t, "tools", "gen-pki", "github.com", "--sub-alt-name", "google.com")
 		require.NoError(t, err, stdOut, stdErr)
diff --git a/src/test/e2e/01_component_choice_test.go b/src/test/e2e/01_component_choice_test.go
index 8668586956..b16efcb3e8 100644
--- a/src/test/e2e/01_component_choice_test.go
+++ b/src/test/e2e/01_component_choice_test.go
@@ -19,7 +19,7 @@ func TestComponentChoice(t *testing.T) {
 		secondFile = "second-choice-file.txt"
 	)
 	t.Cleanup(func() {
-		e2e.CleanFiles(firstFile, secondFile)
+		e2e.CleanFiles(t, firstFile, secondFile)
 	})
 
 	path := fmt.Sprintf("build/zarf-package-component-choice-%s.tar.zst", e2e.Arch)
diff --git a/src/test/e2e/02_component_actions_test.go b/src/test/e2e/02_component_actions_test.go
index 8ef710ee90..47804677f2 100644
--- a/src/test/e2e/02_component_actions_test.go
+++ b/src/test/e2e/02_component_actions_test.go
@@ -26,8 +26,8 @@ func TestComponentActions(t *testing.T) {
 	}
 
 	allArtifacts := append(deployArtifacts, createArtifacts...)
-	e2e.CleanFiles(allArtifacts...)
-	defer e2e.CleanFiles(allArtifacts...)
+	e2e.CleanFiles(t, allArtifacts...)
+	defer e2e.CleanFiles(t, allArtifacts...)
 
 	/* Create */
 	// Try creating the package to test the onCreate actions.
@@ -111,7 +111,7 @@ func TestComponentActions(t *testing.T) {
 		require.FileExists(t, deployWithEnvVarArtifact)
 
 		// Remove the env var file at the end of the test
-		e2e.CleanFiles(deployWithEnvVarArtifact)
+		e2e.CleanFiles(t, deployWithEnvVarArtifact)
 	})
 
 	t.Run("action on-deploy-with-template", func(t *testing.T) {
@@ -128,7 +128,7 @@ func TestComponentActions(t *testing.T) {
 		require.Contains(t, string(outTemplated), "The snake says ###ZARF_VAR_SNAKE_SOUND###")
 
 		// Remove the templated file so we can test with dynamic variables
-		e2e.CleanFiles(deployTemplatedArtifact)
+		e2e.CleanFiles(t, deployTemplatedArtifact)
 
 		// Test using a templated file with dynamic variables
 		stdOut, stdErr, err = e2e.Zarf(t, "package", "deploy", path, "--components=on-deploy-with-template-use-of-variable,on-deploy-with-dynamic-variable,on-deploy-with-multiple-variables", "--confirm")
@@ -140,7 +140,7 @@ func TestComponentActions(t *testing.T) {
 		require.Contains(t, string(outTemplated), "The snake says hiss")
 
 		// Remove the templated file at the end of the test
-		e2e.CleanFiles(deployTemplatedArtifact)
+		e2e.CleanFiles(t, deployTemplatedArtifact)
 	})
 
 	t.Run("action on-deploy-immediate-failure", func(t *testing.T) {
diff --git a/src/test/e2e/03_deprecations_test.go b/src/test/e2e/03_deprecations_test.go
index 0414a3915e..27fcc4a59a 100644
--- a/src/test/e2e/03_deprecations_test.go
+++ b/src/test/e2e/03_deprecations_test.go
@@ -24,14 +24,14 @@ func TestDeprecatedComponentScripts(t *testing.T) {
 		"test-deprecated-deploy-after-hook.txt",
 	}
 	allArtifacts := append(deployArtifacts, prepareArtifact)
-	e2e.CleanFiles(allArtifacts...)
-	defer e2e.CleanFiles(allArtifacts...)
+	e2e.CleanFiles(t, allArtifacts...)
+	defer e2e.CleanFiles(t, allArtifacts...)
 
 	// 1. Try creating the package to test the create scripts
 	testPackagePath := fmt.Sprintf("%s/zarf-package-deprecated-component-scripts-%s.tar.zst", testPackageDirPath, e2e.Arch)
 	outputFlag := fmt.Sprintf("-o=%s", testPackageDirPath)
 	stdOut, stdErr, err := e2e.Zarf(t, "package", "create", testPackageDirPath, outputFlag, "--confirm")
-	defer e2e.CleanFiles(testPackagePath)
+	defer e2e.CleanFiles(t, testPackagePath)
 	require.NoError(t, err, stdOut, stdErr)
 	require.Contains(t, stdErr, "Component '1-test-deprecated-prepare-scripts' is using scripts")
 	require.Contains(t, stdErr, "Component '2-test-deprecated-deploy-scripts' is using scripts")
@@ -71,8 +71,8 @@ func TestDeprecatedSetAndPackageVariables(t *testing.T) {
 		"test-deprecated-deploy-after-hook.txt",
 	}
 	allArtifacts := append(deployArtifacts, prepareArtifact)
-	e2e.CleanFiles(allArtifacts...)
-	defer e2e.CleanFiles(allArtifacts...)
+	e2e.CleanFiles(t, allArtifacts...)
+	defer e2e.CleanFiles(t, allArtifacts...)
 
 	// 2. Try creating the package to test the create scripts
 	testPackagePath := fmt.Sprintf("%s/zarf-package-deprecated-set-variable-%s.tar.zst", testPackageDirPath, e2e.Arch)
@@ -85,7 +85,7 @@ func TestDeprecatedSetAndPackageVariables(t *testing.T) {
 
 	// Check that the command displays a warning on create
 	stdOut, stdErr, err = e2e.Zarf(t, "package", "create", testPackageDirPath, outputFlag, "--confirm", "--set", "ECHO=Zarf-The-Axolotl")
-	defer e2e.CleanFiles(testPackagePath)
+	defer e2e.CleanFiles(t, testPackagePath)
 	require.NoError(t, err, stdOut, stdErr)
 	require.Contains(t, stdErr, "Component '1-test-deprecated-set-variable' is using setVariable")
 	require.Contains(t, stdErr, "deprecated syntax ###ZARF_PKG_VAR_ECHO###")
diff --git a/src/test/e2e/04_create_templating_test.go b/src/test/e2e/04_create_templating_test.go
index a93f23027d..fb03553553 100644
--- a/src/test/e2e/04_create_templating_test.go
+++ b/src/test/e2e/04_create_templating_test.go
@@ -65,5 +65,5 @@ func TestCreateTemplating(t *testing.T) {
 	require.NoError(t, err)
 	require.Contains(t, string(filesJSON), "pandas")
 
-	e2e.CleanFiles(pkgName, fileFoldersPkgName)
+	e2e.CleanFiles(t, pkgName, fileFoldersPkgName)
 }
diff --git a/src/test/e2e/05_tarball_test.go b/src/test/e2e/05_tarball_test.go
index d1646899cf..5ab956c5a0 100644
--- a/src/test/e2e/05_tarball_test.go
+++ b/src/test/e2e/05_tarball_test.go
@@ -28,7 +28,7 @@ func TestMultiPartPackage(t *testing.T) {
 		outputFile = "multi-part-demo.dat"
 	)
 
-	e2e.CleanFiles(deployPath, outputFile)
+	e2e.CleanFiles(t, deployPath, outputFile)
 
 	// Create the package with a max size of 20MB
 	stdOut, stdErr, err := e2e.Zarf(t, "package", "create", createPath, "--max-package-size=20", "--confirm")
@@ -73,8 +73,8 @@ func TestMultiPartPackage(t *testing.T) {
 	err = helpers.SHAsMatch(parts[0], pkgData.Sha256Sum)
 	require.NoError(t, err)
 
-	e2e.CleanFiles(parts...)
-	e2e.CleanFiles(outputFile)
+	e2e.CleanFiles(t, parts...)
+	e2e.CleanFiles(t, outputFile)
 }
 
 func TestReproducibleTarballs(t *testing.T) {
@@ -98,7 +98,7 @@ func TestReproducibleTarballs(t *testing.T) {
 	err = utils.ReadYaml(filepath.Join(unpack1, layout.ZarfYAML), &pkg1)
 	require.NoError(t, err)
 
-	e2e.CleanFiles(unpack1, tb)
+	e2e.CleanFiles(t, unpack1, tb)
 
 	stdOut, stdErr, err = e2e.Zarf(t, "package", "create", createPath, "--confirm", "--output", tmp)
 	require.NoError(t, err, stdOut, stdErr)
diff --git a/src/test/e2e/06_create_sbom_test.go b/src/test/e2e/06_create_sbom_test.go
index a3ee3b4118..0254c56e25 100644
--- a/src/test/e2e/06_create_sbom_test.go
+++ b/src/test/e2e/06_create_sbom_test.go
@@ -29,7 +29,7 @@ func TestCreateSBOM(t *testing.T) {
 	require.FileExists(t, filepath.Join(sbomPath, "dos-games", "ghcr.io_zarf-dev_doom-game_0.0.1.json"))
 
 	// Clean the SBOM path so it is force to be recreated
-	e2e.CleanFiles(sbomPath)
+	e2e.CleanFiles(t, sbomPath)
 
 	stdOut, stdErr, err = e2e.Zarf(t, "package", "inspect", pkgName, "--sbom-out", sbomPath)
 	require.NoError(t, err, stdOut, stdErr)
@@ -68,5 +68,5 @@ func TestCreateSBOM(t *testing.T) {
 	_, err = os.ReadFile(filepath.Join(sbomPath, "init", "compare.html"))
 	require.NoError(t, err)
 
-	e2e.CleanFiles(pkgName)
+	e2e.CleanFiles(t, pkgName)
 }
diff --git a/src/test/e2e/07_create_git_test.go b/src/test/e2e/07_create_git_test.go
index 7a08043c1f..7ec0302e20 100644
--- a/src/test/e2e/07_create_git_test.go
+++ b/src/test/e2e/07_create_git_test.go
@@ -23,7 +23,7 @@ func TestCreateGit(t *testing.T) {
 	path := fmt.Sprintf("build/zarf-package-git-data-%s-0.0.1.tar.zst", e2e.Arch)
 	stdOut, stdErr, err := e2e.Zarf(t, "tools", "archiver", "decompress", path, extractDir, "--unarchive-all")
 	require.NoError(t, err, stdOut, stdErr)
-	defer e2e.CleanFiles(extractDir)
+	defer e2e.CleanFiles(t, extractDir)
 
 	// Verify the full-repo component
 	gitDir := fmt.Sprintf("%s/components/full-repo/repos/zarf-public-test-2395699829/.git", extractDir)
diff --git a/src/test/e2e/08_create_differential_test.go b/src/test/e2e/08_create_differential_test.go
index 59e298c22d..35be26761f 100644
--- a/src/test/e2e/08_create_differential_test.go
+++ b/src/test/e2e/08_create_differential_test.go
@@ -30,7 +30,7 @@ func TestCreateDifferential(t *testing.T) {
 	// Build the package a first time
 	stdOut, stdErr, err := e2e.Zarf(t, "package", "create", packagePath, "--set=PACKAGE_VERSION=v0.25.0", "--confirm")
 	require.NoError(t, err, stdOut, stdErr)
-	defer e2e.CleanFiles(packageName)
+	defer e2e.CleanFiles(t, packageName)
 
 	// Build the differential package without changing the version
 	_, stdErr, err = e2e.Zarf(t, "package", "create", packagePath, "--set=PACKAGE_VERSION=v0.25.0", differentialFlag, "--confirm")
@@ -40,7 +40,7 @@ func TestCreateDifferential(t *testing.T) {
 	// Build the differential package
 	stdOut, stdErr, err = e2e.Zarf(t, "package", "create", packagePath, "--set=PACKAGE_VERSION=v0.26.0", differentialFlag, "--confirm")
 	require.NoError(t, err, stdOut, stdErr)
-	defer e2e.CleanFiles(differentialPackageName)
+	defer e2e.CleanFiles(t, differentialPackageName)
 
 	// Extract the yaml of the differential package
 	err = archiver.Extract(differentialPackageName, layout.ZarfYAML, tmpdir)
diff --git a/src/test/e2e/11_oci_pull_inspect_test.go b/src/test/e2e/11_oci_pull_inspect_test.go
index b7d52fecec..356c5be99a 100644
--- a/src/test/e2e/11_oci_pull_inspect_test.go
+++ b/src/test/e2e/11_oci_pull_inspect_test.go
@@ -33,7 +33,7 @@ func (suite *PullInspectTestSuite) SetupSuite() {
 
 func (suite *PullInspectTestSuite) TearDownSuite() {
 	local := fmt.Sprintf("zarf-package-dos-games-%s-1.0.0.tar.zst", e2e.Arch)
-	e2e.CleanFiles(local)
+	e2e.CleanFiles(suite.T(), local)
 }
 
 func (suite *PullInspectTestSuite) Test_0_Pull() {
diff --git a/src/test/e2e/12_lint_test.go b/src/test/e2e/12_lint_test.go
index dea06dd678..2c77b14056 100644
--- a/src/test/e2e/12_lint_test.go
+++ b/src/test/e2e/12_lint_test.go
@@ -29,9 +29,11 @@ func TestLint(t *testing.T) {
 
 		testPackagePath := filepath.Join("src", "test", "packages", "12-lint")
 		configPath := filepath.Join(testPackagePath, "zarf-config.toml")
-		os.Setenv("ZARF_CONFIG", configPath)
+		osSetErr := os.Setenv("ZARF_CONFIG", configPath)
+		require.NoError(t, osSetErr, "Unable to set ZARF_CONFIG")
 		_, stderr, err := e2e.Zarf(t, "dev", "lint", testPackagePath, "-f", "good-flavor")
-		os.Unsetenv("ZARF_CONFIG")
+		osUnsetErr := os.Unsetenv("ZARF_CONFIG")
+		require.NoError(t, osUnsetErr, "Unable to cleanup ZARF_CONFIG")
 		require.Error(t, err, "Require an exit code since there was warnings / errors")
 		strippedStderr := e2e.StripMessageFormatting(stderr)
 
diff --git a/src/test/e2e/14_oci_compose_test.go b/src/test/e2e/14_oci_compose_test.go
index 7159394107..6dfbe1f45c 100644
--- a/src/test/e2e/14_oci_compose_test.go
+++ b/src/test/e2e/14_oci_compose_test.go
@@ -137,45 +137,54 @@ func (suite *PublishCopySkeletonSuite) Test_2_FilePaths() {
 	}
 
 	for _, pkgTar := range pkgTars {
-		var pkg v1alpha1.ZarfPackage
-
-		unpacked := strings.TrimSuffix(pkgTar, ".tar.zst")
-		defer os.RemoveAll(unpacked)
-		defer os.RemoveAll(pkgTar)
-		_, _, err := e2e.Zarf(suite.T(), "tools", "archiver", "decompress", pkgTar, unpacked, "--unarchive-all")
-		suite.NoError(err)
-		suite.DirExists(unpacked)
-
-		// Verify skeleton contains kustomize-generated manifests.
-		if strings.HasSuffix(pkgTar, "zarf-package-test-compose-package-skeleton-0.0.1.tar.zst") {
-			kustomizeGeneratedManifests := []string{
-				"kustomization-connect-service-0.yaml",
-				"kustomization-connect-service-1.yaml",
-				"kustomization-connect-service-two-0.yaml",
-			}
-			manifestDir := filepath.Join(unpacked, "components", "test-compose-package", "manifests")
-			for _, manifest := range kustomizeGeneratedManifests {
-				manifestPath := filepath.Join(manifestDir, manifest)
-				suite.FileExists(manifestPath, "expected to find kustomize-generated manifest: %q", manifestPath)
-				var configMap corev1.ConfigMap
-				err := utils.ReadYaml(manifestPath, &configMap)
-				suite.NoError(err)
-				suite.Equal("ConfigMap", configMap.Kind, "expected manifest %q to be of kind ConfigMap", manifestPath)
+		// Wrap in a fn to ensure our defers cleanup resources on each iteration
+		func() {
+			var pkg v1alpha1.ZarfPackage
+
+			unpacked := strings.TrimSuffix(pkgTar, ".tar.zst")
+			_, _, err := e2e.Zarf(suite.T(), "tools", "archiver", "decompress", pkgTar, unpacked, "--unarchive-all")
+			suite.NoError(err)
+			suite.DirExists(unpacked)
+
+			// Cleanup resources
+			defer func() {
+				suite.NoError(os.RemoveAll(unpacked))
+			}()
+			defer func() {
+				suite.NoError(os.RemoveAll(pkgTar))
+			}()
+
+			// Verify skeleton contains kustomize-generated manifests.
+			if strings.HasSuffix(pkgTar, "zarf-package-test-compose-package-skeleton-0.0.1.tar.zst") {
+				kustomizeGeneratedManifests := []string{
+					"kustomization-connect-service-0.yaml",
+					"kustomization-connect-service-1.yaml",
+					"kustomization-connect-service-two-0.yaml",
+				}
+				manifestDir := filepath.Join(unpacked, "components", "test-compose-package", "manifests")
+				for _, manifest := range kustomizeGeneratedManifests {
+					manifestPath := filepath.Join(manifestDir, manifest)
+					suite.FileExists(manifestPath, "expected to find kustomize-generated manifest: %q", manifestPath)
+					var configMap corev1.ConfigMap
+					err := utils.ReadYaml(manifestPath, &configMap)
+					suite.NoError(err)
+					suite.Equal("ConfigMap", configMap.Kind, "expected manifest %q to be of kind ConfigMap", manifestPath)
+				}
 			}
-		}
 
-		err = utils.ReadYaml(filepath.Join(unpacked, layout.ZarfYAML), &pkg)
-		suite.NoError(err)
-		suite.NotNil(pkg)
+			err = utils.ReadYaml(filepath.Join(unpacked, layout.ZarfYAML), &pkg)
+			suite.NoError(err)
+			suite.NotNil(pkg)
 
-		components := pkg.Components
-		suite.NotNil(components)
+			components := pkg.Components
+			suite.NotNil(components)
 
-		isSkeleton := false
-		if strings.Contains(pkgTar, "-skeleton-") {
-			isSkeleton = true
-		}
-		suite.verifyComponentPaths(unpacked, components, isSkeleton)
+			isSkeleton := false
+			if strings.Contains(pkgTar, "-skeleton-") {
+				isSkeleton = true
+			}
+			suite.verifyComponentPaths(unpacked, components, isSkeleton)
+		}()
 	}
 }
 
diff --git a/src/test/e2e/20_zarf_init_test.go b/src/test/e2e/20_zarf_init_test.go
index c94bfa4226..de981f9b13 100644
--- a/src/test/e2e/20_zarf_init_test.go
+++ b/src/test/e2e/20_zarf_init_test.go
@@ -32,7 +32,7 @@ func TestZarfInit(t *testing.T) {
 		expectedErrorMessage  = "unable to run component before action: command \"Check that the host architecture matches the package architecture\""
 	)
 	t.Cleanup(func() {
-		e2e.CleanFiles(mismatchedInitPackage)
+		e2e.CleanFiles(t, mismatchedInitPackage)
 	})
 
 	if runtime.GOOS == "linux" {
@@ -104,8 +104,8 @@ func TestZarfInit(t *testing.T) {
 	verifyZarfServiceLabels(t)
 
 	// Special sizing-hacking for reducing resources where Kind + CI eats a lot of free cycles (ignore errors)
-	_, _, _ = e2e.Kubectl(t, "scale", "deploy", "-n", "kube-system", "coredns", "--replicas=1")
-	_, _, _ = e2e.Kubectl(t, "scale", "deploy", "-n", "zarf", "agent-hook", "--replicas=1")
+	_, _, _ = e2e.Kubectl(t, "scale", "deploy", "-n", "kube-system", "coredns", "--replicas=1") // TODO(mkcp): intentionally ignored, mark nolint
+	_, _, _ = e2e.Kubectl(t, "scale", "deploy", "-n", "zarf", "agent-hook", "--replicas=1")     // TODO(mkcp): intentionally ignored, mark nolint
 }
 
 func checkLogForSensitiveState(t *testing.T, logText string, zarfState types.ZarfState) {
diff --git a/src/test/e2e/21_connect_creds_test.go b/src/test/e2e/21_connect_creds_test.go
index c58244a736..c3d174ae65 100644
--- a/src/test/e2e/21_connect_creds_test.go
+++ b/src/test/e2e/21_connect_creds_test.go
@@ -74,7 +74,9 @@ func TestMetrics(t *testing.T) {
 	if err != nil {
 		t.Fatal(err)
 	}
-	defer resp.Body.Close()
+	defer func() {
+		require.NoError(t, resp.Body.Close())
+	}()
 
 	// Read the response body
 	body, err := io.ReadAll(resp.Body)
diff --git a/src/test/e2e/22_git_and_gitops_test.go b/src/test/e2e/22_git_and_gitops_test.go
index 901137125b..90eb715259 100644
--- a/src/test/e2e/22_git_and_gitops_test.go
+++ b/src/test/e2e/22_git_and_gitops_test.go
@@ -27,7 +27,7 @@ func TestGit(t *testing.T) {
 	require.NoError(t, err, stdOut, stdErr)
 
 	path := fmt.Sprintf("build/zarf-package-git-data-test-%s-1.0.0.tar.zst", e2e.Arch)
-	defer e2e.CleanFiles(path)
+	defer e2e.CleanFiles(t, path)
 
 	// Deploy the git data example (with component globbing to test that as well)
 	stdOut, stdErr, err = e2e.Zarf(t, "package", "deploy", path, "--components=full-repo,specific-*", "--confirm")
diff --git a/src/test/e2e/24_variables_test.go b/src/test/e2e/24_variables_test.go
index f5b06116d0..b583a314d4 100644
--- a/src/test/e2e/24_variables_test.go
+++ b/src/test/e2e/24_variables_test.go
@@ -24,7 +24,7 @@ func TestVariables(t *testing.T) {
 
 	tfPath := "modified-terraform.tf"
 
-	e2e.CleanFiles(tfPath, evilPath)
+	e2e.CleanFiles(t, tfPath, evilPath)
 
 	// Test that specifying an invalid setVariable value results in an error
 	stdOut, stdErr, err := e2e.Zarf(t, "package", "create", evilSrc, "--set", "NUMB3R5=K1TT3H", "--confirm")
@@ -43,8 +43,9 @@ func TestVariables(t *testing.T) {
 	require.Contains(t, stdErr, "", expectedOutString)
 
 	// Test that not specifying a prompted variable results in an error
-	_, stdErr, _ = e2e.Zarf(t, "package", "deploy", path, "--confirm")
+	_, stdErr, err = e2e.Zarf(t, "package", "deploy", path, "--confirm")
 	expectedOutString = "variable 'SITE_NAME' must be '--set' when using the '--confirm' flag"
+	require.Error(t, err)
 	require.Contains(t, stdErr, "", expectedOutString)
 
 	// Test that specifying an invalid variable value results in an error
@@ -73,7 +74,8 @@ func TestVariables(t *testing.T) {
 	require.Contains(t, string(outputTF), "unicorn-land")
 
 	// Verify the configmap was properly templated
-	kubectlOut, _, _ := e2e.Kubectl(t, "-n", "nginx", "get", "configmap", "nginx-configmap", "-o", "jsonpath='{.data.index\\.html}' ")
+	kubectlOut, _, err := e2e.Kubectl(t, "-n", "nginx", "get", "configmap", "nginx-configmap", "-o", "jsonpath='{.data.index\\.html}' ")
+	require.NoError(t, err, "unable to get nginx configmap")
 	// OPTIONAL_FOOTER should remain unset because it was not set during deploy
 	require.Contains(t, string(kubectlOut), "</pre>\n    \n  </body>")
 	// STYLE should take the default value
@@ -91,5 +93,5 @@ func TestVariables(t *testing.T) {
 	stdOut, stdErr, err = e2e.Zarf(t, "package", "remove", path, "--confirm")
 	require.NoError(t, err, stdOut, stdErr)
 
-	e2e.CleanFiles(tfPath, evilPath)
+	e2e.CleanFiles(t, tfPath, evilPath)
 }
diff --git a/src/test/e2e/25_helm_test.go b/src/test/e2e/25_helm_test.go
index 3e51900cdd..421b62ed0a 100644
--- a/src/test/e2e/25_helm_test.go
+++ b/src/test/e2e/25_helm_test.go
@@ -38,7 +38,7 @@ func testHelmChartsExample(t *testing.T) {
 	localTgzChartPath := filepath.Join("src", "test", "packages", "25-local-tgz-chart")
 	stdOut, stdErr, err := e2e.Zarf(t, "package", "create", localTgzChartPath, "--tmpdir", tmpdir, "--confirm")
 	require.NoError(t, err, stdOut, stdErr)
-	defer e2e.CleanFiles(fmt.Sprintf("zarf-package-helm-charts-local-tgz-%s-0.0.1.tar.zst", e2e.Arch))
+	defer e2e.CleanFiles(t, fmt.Sprintf("zarf-package-helm-charts-local-tgz-%s-0.0.1.tar.zst", e2e.Arch))
 
 	// Create a package that needs dependencies
 	evilChartDepsPath := filepath.Join("src", "test", "packages", "25-evil-chart-deps")
@@ -99,7 +99,8 @@ func testHelmEscaping(t *testing.T) {
 	require.NoError(t, err, stdOut, stdErr)
 
 	// Verify the configmap was deployed, escaped, and contains all of its data
-	kubectlOut, _ := exec.Command("kubectl", "-n", "default", "describe", "cm", "dont-template-me").Output()
+	kubectlOut, err := exec.Command("kubectl", "-n", "default", "describe", "cm", "dont-template-me").Output()
+	require.NoError(t, err, "unable to describe configmap")
 	require.Contains(t, string(kubectlOut), `alert: OOMKilled {{ "{{ \"random.Values\" }}" }}`)
 	require.Contains(t, string(kubectlOut), "backtick1: \"content with backticks `some random things`\"")
 	require.Contains(t, string(kubectlOut), "backtick2: \"nested templating with backticks {{` random.Values `}}\"")
@@ -175,8 +176,9 @@ func testHelmAdoption(t *testing.T) {
 	deploymentManifest := "src/test/packages/25-manifest-adoption/deployment.yaml"
 
 	// Deploy dos-games manually into the cluster without Zarf
-	kubectlOut, _, _ := e2e.Kubectl(t, "apply", "-f", deploymentManifest)
-	require.Contains(t, string(kubectlOut), "deployment.apps/game created")
+	kubectlOut, _, err := e2e.Kubectl(t, "apply", "-f", deploymentManifest)
+	require.NoError(t, err, "unable to apply", "deploymentManifest", deploymentManifest)
+	require.Contains(t, kubectlOut, "deployment.apps/game created")
 
 	// Deploy dos-games into the cluster with Zarf
 	stdOut, stdErr, err := e2e.Zarf(t, "package", "deploy", packagePath, "--confirm", "--adopt-existing-resources")
diff --git a/src/test/e2e/28_wait_test.go b/src/test/e2e/28_wait_test.go
index e67b60d178..aeaea654df 100644
--- a/src/test/e2e/28_wait_test.go
+++ b/src/test/e2e/28_wait_test.go
@@ -51,7 +51,7 @@ func TestNoWait(t *testing.T) {
 	case <-time.After(30 * time.Second):
 		t.Error("Timeout waiting for zarf deploy (it tried to wait)")
 		t.Log("Removing hanging namespace...")
-		_, _, _ = e2e.Kubectl(t, "delete", "namespace", "no-wait", "--force=true", "--wait=false", "--grace-period=0")
+		_, _, _ = e2e.Kubectl(t, "delete", "namespace", "no-wait", "--force=true", "--wait=false", "--grace-period=0") // TODO(mkcp): intentionally ignored, mark nolint
 	}
 	require.NoError(t, err, stdOut, stdErr)
 
diff --git a/src/test/e2e/29_config_file_test.go b/src/test/e2e/29_config_file_test.go
index 0cea0b4dd9..bcef00ad87 100644
--- a/src/test/e2e/29_config_file_test.go
+++ b/src/test/e2e/29_config_file_test.go
@@ -13,6 +13,8 @@ import (
 	"github.com/stretchr/testify/require"
 )
 
+const envKey = "ZARF_CONFIG"
+
 func TestConfigFile(t *testing.T) {
 	t.Log("E2E: Config file")
 
@@ -22,11 +24,13 @@ func TestConfigFile(t *testing.T) {
 		config = "zarf-config.toml"
 	)
 
-	e2e.CleanFiles(path)
+	e2e.CleanFiles(t, path)
 
 	// Test the config file environment variable
-	t.Setenv("ZARF_CONFIG", filepath.Join(dir, config))
-	defer os.Unsetenv("ZARF_CONFIG")
+	t.Setenv(envKey, filepath.Join(dir, config))
+	defer func() {
+		require.NoError(t, os.Unsetenv(envKey))
+	}()
 	configFileTests(t, dir, path)
 
 	configFileDefaultTests(t)
@@ -34,7 +38,8 @@ func TestConfigFile(t *testing.T) {
 	stdOut, stdErr, err := e2e.Zarf(t, "package", "remove", path, "--confirm")
 	require.NoError(t, err, stdOut, stdErr)
 
-	e2e.CleanFiles(path)
+	// Cleanup
+	e2e.CleanFiles(t, path)
 }
 
 func configFileTests(t *testing.T, dir, path string) {
@@ -139,30 +144,36 @@ 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")
+	t.Setenv(envKey, filepath.Join("src", "test", "zarf-config-test.toml"))
+	defer func() {
+		require.NoError(t, os.Unsetenv(envKey))
+	}()
 
 	// Test global flags
-	stdOut, _, _ := e2e.Zarf(t, "--help")
+	stdOut, _, err := e2e.Zarf(t, "--help")
+	require.NoError(t, err)
 	for _, test := range globalFlags {
-		require.Contains(t, string(stdOut), test)
+		require.Contains(t, stdOut, test)
 	}
 
 	// Test init flags
-	stdOut, _, _ = e2e.Zarf(t, "init", "--help")
+	stdOut, _, err = e2e.Zarf(t, "init", "--help")
+	require.NoError(t, err)
 	for _, test := range initFlags {
-		require.Contains(t, string(stdOut), test)
+		require.Contains(t, stdOut, test)
 	}
 
 	// Test package create flags
-	stdOut, _, _ = e2e.Zarf(t, "package", "create", "--help")
+	stdOut, _, err = e2e.Zarf(t, "package", "create", "--help")
+	require.NoError(t, err)
 	for _, test := range packageCreateFlags {
-		require.Contains(t, string(stdOut), test)
+		require.Contains(t, stdOut, test)
 	}
 
 	// Test package deploy flags
-	stdOut, _, _ = e2e.Zarf(t, "package", "deploy", "--help")
+	stdOut, _, err = e2e.Zarf(t, "package", "deploy", "--help")
+	require.NoError(t, err)
 	for _, test := range packageDeployFlags {
-		require.Contains(t, string(stdOut), test)
+		require.Contains(t, stdOut, test)
 	}
 }
diff --git a/src/test/e2e/30_component_action_cluster_test.go b/src/test/e2e/30_component_action_cluster_test.go
index 6763a042dc..16ead6ef8d 100644
--- a/src/test/e2e/30_component_action_cluster_test.go
+++ b/src/test/e2e/30_component_action_cluster_test.go
@@ -36,7 +36,7 @@ func TestComponentActionEdgeCases(t *testing.T) {
 
 	stdOut, stdErr, err := e2e.Zarf(t, "package", "create", sourcePath, "--confirm")
 	require.NoError(t, err, stdOut, stdErr)
-	defer e2e.CleanFiles(packagePath)
+	defer e2e.CleanFiles(t, packagePath)
 
 	stdOut, stdErr, err = e2e.Zarf(t, "package", "deploy", packagePath, "--confirm")
 	require.NoError(t, err, stdOut, stdErr)
diff --git a/src/test/e2e/31_checksum_and_signature_test.go b/src/test/e2e/31_checksum_and_signature_test.go
index 5e60466b91..c6897c8cee 100644
--- a/src/test/e2e/31_checksum_and_signature_test.go
+++ b/src/test/e2e/31_checksum_and_signature_test.go
@@ -21,7 +21,7 @@ func TestChecksumAndSignature(t *testing.T) {
 
 	stdOut, stdErr, err := e2e.Zarf(t, "package", "create", testPackageDirPath, privateKeyFlag, "--confirm")
 	require.NoError(t, err, stdOut, stdErr)
-	defer e2e.CleanFiles(pkgName)
+	defer e2e.CleanFiles(t, pkgName)
 
 	// Test that we don't get an error when we remember to provide the public key
 	stdOut, stdErr, err = e2e.Zarf(t, "package", "inspect", pkgName, publicKeyFlag)
diff --git a/src/test/e2e/32_component_webhooks_test.go b/src/test/e2e/32_component_webhooks_test.go
index 18c9ed33cc..936d9b7e54 100644
--- a/src/test/e2e/32_component_webhooks_test.go
+++ b/src/test/e2e/32_component_webhooks_test.go
@@ -20,7 +20,7 @@ func TestComponentWebhooks(t *testing.T) {
 	require.NoError(t, err, stdOut, stdErr)
 	stdOut, stdErr, err = e2e.Zarf(t, "tools", "wait-for", "deployment", "pepr-cb5693ef-d13c-5fe1-b5ad-c870fd911b3b", "available", "-n=pepr-system")
 	require.NoError(t, err, stdOut, stdErr)
-	defer e2e.CleanFiles(webhookPath)
+	defer e2e.CleanFiles(t, webhookPath)
 
 	// Ensure package deployments wait for webhooks to complete.
 	gamesPath := fmt.Sprintf("build/zarf-package-dos-games-%s-1.1.0.tar.zst", e2e.Arch)
diff --git a/src/test/e2e/33_manifest_with_symlink_test.go b/src/test/e2e/33_manifest_with_symlink_test.go
index 9748154dc7..441915581a 100644
--- a/src/test/e2e/33_manifest_with_symlink_test.go
+++ b/src/test/e2e/33_manifest_with_symlink_test.go
@@ -22,10 +22,10 @@ func TestManifestWithSymlink(t *testing.T) {
 
 	path := fmt.Sprintf("build/zarf-package-manifest-with-symlink-%s-0.0.1.tar.zst", e2e.Arch)
 	require.FileExists(t, path)
-	defer e2e.CleanFiles(path)
+	defer e2e.CleanFiles(t, path)
 
 	stdOut, stdErr, err = e2e.Zarf(t, "package", "deploy", path, "--confirm")
-	defer e2e.CleanFiles("temp/manifests")
+	defer e2e.CleanFiles(t, "temp/manifests")
 	require.NoError(t, err, stdOut, stdErr)
 	require.FileExists(t, "temp/manifests/resources/img", "Symlink does not exist in the package as expected.")
 }
diff --git a/src/test/e2e/34_custom_init_package_test.go b/src/test/e2e/34_custom_init_package_test.go
index e3dbeeeeef..b49935e87e 100644
--- a/src/test/e2e/34_custom_init_package_test.go
+++ b/src/test/e2e/34_custom_init_package_test.go
@@ -22,7 +22,7 @@ func TestCustomInit(t *testing.T) {
 
 	stdOut, stdErr, err := e2e.Zarf(t, "package", "create", buildPath, privateKeyFlag, "--confirm")
 	require.NoError(t, err, stdOut, stdErr)
-	defer e2e.CleanFiles(pkgName)
+	defer e2e.CleanFiles(t, pkgName)
 
 	/* Test operations during package inspect */
 	// Test that we can inspect the yaml of the package without the private key
diff --git a/src/test/e2e/50_oci_publish_deploy_test.go b/src/test/e2e/50_oci_publish_deploy_test.go
index 88ea94fcf0..4c2e250551 100644
--- a/src/test/e2e/50_oci_publish_deploy_test.go
+++ b/src/test/e2e/50_oci_publish_deploy_test.go
@@ -37,7 +37,7 @@ func (suite *PublishDeploySuiteTestSuite) SetupSuite() {
 
 func (suite *PublishDeploySuiteTestSuite) TearDownSuite() {
 	local := fmt.Sprintf("zarf-package-helm-charts-%s-0.0.1.tar.zst", e2e.Arch)
-	e2e.CleanFiles(local)
+	e2e.CleanFiles(suite.Suite.T(), local)
 }
 
 func (suite *PublishDeploySuiteTestSuite) Test_0_Publish() {
@@ -103,7 +103,7 @@ func (suite *PublishDeploySuiteTestSuite) Test_2_Pull_And_Deploy() {
 	suite.T().Log("E2E: Package Pull oci:// && Package Deploy tarball")
 
 	local := fmt.Sprintf("zarf-package-helm-charts-%s-0.0.1.tar.zst", e2e.Arch)
-	defer e2e.CleanFiles(local)
+	defer e2e.CleanFiles(suite.T(), local)
 	// Verify the package was pulled.
 	suite.FileExists(local)
 
diff --git a/src/test/external/common.go b/src/test/external/common.go
index 5fd2e294f2..82fb0dabd4 100644
--- a/src/test/external/common.go
+++ b/src/test/external/common.go
@@ -29,7 +29,8 @@ func createPodInfoPackageWithInsecureSources(t *testing.T, temp string) {
 	require.NoError(t, err, "unable to yq edit helm source")
 	err = exec.CmdWithPrint(zarfBinPath, "tools", "yq", "eval", ".spec.insecure = true", "-i", filepath.Join(temp, "oci", "podinfo-source.yaml"))
 	require.NoError(t, err, "unable to yq edit oci source")
-	exec.CmdWithPrint(zarfBinPath, "package", "create", temp, "--confirm", "--output", temp)
+	err = exec.CmdWithPrint(zarfBinPath, "package", "create", temp, "--confirm", "--output", temp)
+	require.NoError(t, err, "unable to create package")
 }
 
 func waitForCondition(t *testing.T, timeoutMinutes time.Duration, cmd string, args []string, condition string) error {
diff --git a/src/test/external/ext_in_cluster_test.go b/src/test/external/ext_in_cluster_test.go
index ad1e338935..81102c0b14 100644
--- a/src/test/external/ext_in_cluster_test.go
+++ b/src/test/external/ext_in_cluster_test.go
@@ -154,10 +154,14 @@ func (suite *ExtInClusterTestSuite) Test_1_Deploy() {
 	// Use Zarf to initialize the cluster
 	initArgs := []string{"init", "--confirm"}
 	initArgs = append(initArgs, inClusterInitCredentialArgs...)
+
 	err := exec.CmdWithPrint(zarfBinPath, initArgs...)
 	suite.NoError(err, "unable to initialize the k8s server with zarf")
+
 	temp := suite.T().TempDir()
-	defer os.Remove(temp)
+	defer func() {
+		suite.NoError(os.RemoveAll(temp), "failed to clean up tempdir")
+	}()
 	createPodInfoPackageWithInsecureSources(suite.T(), temp)
 
 	// Deploy the flux example package
diff --git a/src/test/external/ext_out_cluster_test.go b/src/test/external/ext_out_cluster_test.go
index 1eee15e718..ea0aa85023 100644
--- a/src/test/external/ext_out_cluster_test.go
+++ b/src/test/external/ext_out_cluster_test.go
@@ -58,10 +58,12 @@ func (suite *ExtOutClusterTestSuite) SetupSuite() {
 	suite.Assertions = require.New(suite.T())
 
 	// Teardown any leftovers from previous tests
-	_ = exec.CmdWithPrint("k3d", "cluster", "delete", clusterName)
-	_ = exec.CmdWithPrint("docker", "rm", "-f", "k3d-"+registryHost)
-	_ = exec.CmdWithPrint("docker", "compose", "down")
-	_ = exec.CmdWithPrint("docker", "network", "remove", network)
+	// NOTE(mkcp): We dogsled these errors because some of these commands will error if they don't cleanup a resource,
+	//   which is ok. A better solution would be checking for none or unexpected kinds of errors.
+	_ = exec.CmdWithPrint("k3d", "cluster", "delete", clusterName)   // TODO(mkcp): intentionally ignored, mark nolint
+	_ = exec.CmdWithPrint("docker", "rm", "-f", "k3d-"+registryHost) // TODO(mkcp): intentionally ignored, mark nolint
+	_ = exec.CmdWithPrint("docker", "compose", "down")               // TODO(mkcp): intentionally ignored, mark nolint
+	_ = exec.CmdWithPrint("docker", "network", "remove", network)    // TODO(mkcp): intentionally ignored, mark nolint
 
 	// Setup a network for everything to live inside
 	err := exec.CmdWithPrint("docker", "network", "create", "--driver=bridge", "--subnet="+subnet, "--gateway="+gateway, network)
@@ -146,7 +148,9 @@ func (suite *ExtOutClusterTestSuite) Test_1_Deploy() {
 func (suite *ExtOutClusterTestSuite) Test_2_DeployGitOps() {
 	// Deploy the flux example package
 	temp := suite.T().TempDir()
-	defer os.Remove(temp)
+	defer func() {
+		suite.NoError(os.RemoveAll(temp), "unable to remove temporary directory")
+	}()
 	createPodInfoPackageWithInsecureSources(suite.T(), temp)
 
 	deployArgs := []string{"package", "deploy", filepath.Join(temp, "zarf-package-podinfo-flux-amd64.tar.zst"), "--confirm"}
@@ -161,18 +165,22 @@ func (suite *ExtOutClusterTestSuite) Test_2_DeployGitOps() {
 
 func (suite *ExtOutClusterTestSuite) Test_3_AuthToPrivateHelmChart() {
 	baseURL := fmt.Sprintf("http://%s:3000", giteaHost)
+	envKey := "HELM_REPOSITORY_CONFIG"
 
 	suite.createHelmChartInGitea(baseURL, giteaUser, commonPassword)
 	suite.makeGiteaUserPrivate(baseURL, giteaUser, commonPassword)
 
 	tempDir := suite.T().TempDir()
 	repoPath := filepath.Join(tempDir, "repositories.yaml")
-	os.Setenv("HELM_REPOSITORY_CONFIG", repoPath)
-	defer os.Unsetenv("HELM_REPOSITORY_CONFIG")
+	err := os.Setenv(envKey, repoPath)
+	suite.NoError(err)
+	defer func() {
+		suite.NoError(os.Unsetenv(envKey))
+	}()
 
 	packagePath := filepath.Join("..", "packages", "external-helm-auth")
 	findImageArgs := []string{"dev", "find-images", packagePath}
-	err := exec.CmdWithPrint(zarfBinPath, findImageArgs...)
+	err = exec.CmdWithPrint(zarfBinPath, findImageArgs...)
 	suite.Error(err, "Since auth has not been setup, this should fail")
 
 	repoFile := repo.NewFile()
@@ -212,7 +220,9 @@ func (suite *ExtOutClusterTestSuite) createHelmChartInGitea(baseURL string, user
 
 	file, err := os.Open(podinfoTarballPath)
 	suite.NoError(err)
-	defer file.Close()
+	defer func() {
+		suite.NoError(file.Close(), "unable to close file")
+	}()
 
 	body := &bytes.Buffer{}
 	writer := multipart.NewWriter(body)
@@ -220,7 +230,8 @@ func (suite *ExtOutClusterTestSuite) createHelmChartInGitea(baseURL string, user
 	suite.NoError(err)
 	_, err = io.Copy(part, file)
 	suite.NoError(err)
-	writer.Close()
+	err = writer.Close()
+	suite.NoError(err, "unable to close writer")
 
 	req, err := http.NewRequest("POST", url, body)
 	suite.NoError(err)
@@ -229,10 +240,10 @@ func (suite *ExtOutClusterTestSuite) createHelmChartInGitea(baseURL string, user
 	req.SetBasicAuth(username, password)
 
 	client := &http.Client{}
-
 	resp, err := client.Do(req)
 	suite.NoError(err)
-	resp.Body.Close()
+	err = resp.Body.Close()
+	suite.NoError(err, "unable to close response body")
 }
 
 func (suite *ExtOutClusterTestSuite) makeGiteaUserPrivate(baseURL string, username string, password string) {
@@ -257,8 +268,9 @@ func (suite *ExtOutClusterTestSuite) makeGiteaUserPrivate(baseURL string, userna
 	client := &http.Client{}
 	resp, err := client.Do(req)
 	suite.NoError(err)
-	defer resp.Body.Close()
-
+	defer func() {
+		suite.NoError(resp.Body.Close())
+	}()
 	_, err = io.ReadAll(resp.Body)
 	suite.NoError(err)
 }
diff --git a/src/test/nightly/ecr_publish_test.go b/src/test/nightly/ecr_publish_test.go
index 2e3a26ae49..7ada0c5eda 100644
--- a/src/test/nightly/ecr_publish_test.go
+++ b/src/test/nightly/ecr_publish_test.go
@@ -65,7 +65,7 @@ func TestECRPublishing(t *testing.T) {
 	// Validate that we can pull the package down from ECR
 	stdOut, stdErr, err = e2e.Zarf(t, "package", "pull", upstreamPackageURL)
 	require.NoError(t, err, stdOut, stdErr)
-	defer e2e.CleanFiles(testPackageFileName)
+	defer e2e.CleanFiles(t, testPackageFileName)
 
 	// Ensure we get a warning when trying to inspect the package without providing the public key
 	// and the insecure flag
diff --git a/src/test/upgrade/previously_built_test.go b/src/test/upgrade/previously_built_test.go
index 0b59761d6d..178a97ca5b 100644
--- a/src/test/upgrade/previously_built_test.go
+++ b/src/test/upgrade/previously_built_test.go
@@ -29,18 +29,24 @@ func TestPreviouslyBuiltZarfPackage(t *testing.T) {
 	t.Log("Upgrade: Previously Built Zarf Package")
 
 	// For the upgrade test, podinfo-upgrade should already be in the cluster (version 6.3.3) (see .github/workflows/test-upgrade.yml)
-	kubectlOut, _, _ := kubectl(t, "-n=podinfo-upgrade", "rollout", "status", "deployment/podinfo-upgrade")
+	kubectlOut, _, err := kubectl(t, "-n=podinfo-upgrade", "rollout", "status", "deployment/podinfo-upgrade")
+	require.NoError(t, err)
 	require.Contains(t, kubectlOut, "successfully rolled out")
-	kubectlOut, _, _ = kubectl(t, "-n=podinfo-upgrade", "get", "deployment", "podinfo-upgrade", "-o=jsonpath={.metadata.labels}}")
+	kubectlOut, _, err = kubectl(t, "-n=podinfo-upgrade", "get", "deployment", "podinfo-upgrade", "-o=jsonpath={.metadata.labels}}")
+	require.NoError(t, err)
 	require.Contains(t, kubectlOut, "6.3.3")
 
 	// Verify that the private-registry secret and private-git-server secret in the podinfo-upgrade namespace are the same after re-init
 	// This tests that `zarf tools update-creds` successfully updated the other namespace
-	zarfRegistrySecret, _, _ := kubectl(t, "-n=zarf", "get", "secret", "private-registry", "-o", "jsonpath={.data}")
-	podinfoRegistrySecret, _, _ := kubectl(t, "-n=podinfo-upgrade", "get", "secret", "private-registry", "-o", "jsonpath={.data}")
+	zarfRegistrySecret, _, err := kubectl(t, "-n=zarf", "get", "secret", "private-registry", "-o", "jsonpath={.data}")
+	require.NoError(t, err)
+	podinfoRegistrySecret, _, err := kubectl(t, "-n=podinfo-upgrade", "get", "secret", "private-registry", "-o", "jsonpath={.data}")
+	require.NoError(t, err)
 	require.Equal(t, zarfRegistrySecret, podinfoRegistrySecret, "the zarf registry secret and podinfo-upgrade registry secret did not match")
-	zarfGitServerSecret, _, _ := kubectl(t, "-n=zarf", "get", "secret", "private-git-server", "-o", "jsonpath={.data}")
-	podinfoGitServerSecret, _, _ := kubectl(t, "-n=podinfo-upgrade", "get", "secret", "private-git-server", "-o", "jsonpath={.data}")
+	zarfGitServerSecret, _, err := kubectl(t, "-n=zarf", "get", "secret", "private-git-server", "-o", "jsonpath={.data}")
+	require.NoError(t, err)
+	podinfoGitServerSecret, _, err := kubectl(t, "-n=podinfo-upgrade", "get", "secret", "private-git-server", "-o", "jsonpath={.data}")
+	require.NoError(t, err)
 	require.Equal(t, zarfGitServerSecret, podinfoGitServerSecret, "the zarf git server secret and podinfo-upgrade git server secret did not match")
 
 	// We also expect a 6.3.4 package to have been previously built
@@ -56,9 +62,11 @@ func TestPreviouslyBuiltZarfPackage(t *testing.T) {
 	require.Contains(t, stdErr, "-----BEGIN PUBLIC KEY-----")
 
 	// Verify that podinfo-upgrade successfully deploys in the cluster (version 6.3.4)
-	kubectlOut, _, _ = kubectl(t, "-n=podinfo-upgrade", "rollout", "status", "deployment/podinfo-upgrade")
+	kubectlOut, _, err = kubectl(t, "-n=podinfo-upgrade", "rollout", "status", "deployment/podinfo-upgrade")
+	require.NoError(t, err)
 	require.Contains(t, kubectlOut, "successfully rolled out")
-	kubectlOut, _, _ = kubectl(t, "-n=podinfo-upgrade", "get", "deployment", "podinfo-upgrade", "-o=jsonpath={.metadata.labels}}")
+	kubectlOut, _, err = kubectl(t, "-n=podinfo-upgrade", "get", "deployment", "podinfo-upgrade", "-o=jsonpath={.metadata.labels}}")
+	require.NoError(t, err)
 	require.Contains(t, kubectlOut, "6.3.4")
 
 	// We also want to build a new package.
@@ -75,9 +83,11 @@ func TestPreviouslyBuiltZarfPackage(t *testing.T) {
 	require.Contains(t, stdErr, "-----BEGIN PUBLIC KEY-----")
 
 	// Verify that podinfo-upgrade successfully deploys in the cluster (version 6.3.5)
-	kubectlOut, _, _ = kubectl(t, "-n=podinfo-upgrade", "rollout", "status", "deployment/podinfo-upgrade")
+	kubectlOut, _, err = kubectl(t, "-n=podinfo-upgrade", "rollout", "status", "deployment/podinfo-upgrade")
+	require.NoError(t, err)
 	require.Contains(t, kubectlOut, "successfully rolled out")
-	kubectlOut, _, _ = kubectl(t, "-n=podinfo-upgrade", "get", "deployment", "podinfo-upgrade", "-o=jsonpath={.metadata.labels}}")
+	kubectlOut, _, err = kubectl(t, "-n=podinfo-upgrade", "get", "deployment", "podinfo-upgrade", "-o=jsonpath={.metadata.labels}}")
+	require.NoError(t, err)
 	require.Contains(t, kubectlOut, "6.3.5")
 
 	// Remove the package.