Skip to content

Commit

Permalink
Correctly cleanup temp directory test (#654)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-mccoy authored Aug 2, 2022
1 parent eebd8c6 commit f885189
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
9 changes: 3 additions & 6 deletions src/test/e2e/01_component_choice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,16 @@ func TestComponentChoice(t *testing.T) {
require.NoError(t, err, stdOut, stdErr)

// Verify the file was created
expectedFile := firstFile
require.FileExists(t, expectedFile)
require.FileExists(t, firstFile)
// Verify the second choice file was not created
expectedFile = secondFile
require.NoFileExists(t, expectedFile)
require.NoFileExists(t, secondFile)

// Deploy using default choice
stdOut, stdErr, err = e2e.execZarfCommand("package", "deploy", path, "--confirm")
require.NoError(t, err, stdOut, stdErr)

// Verify the file was created
expectedFile = secondFile
require.FileExists(t, expectedFile)
require.FileExists(t, secondFile)

e2e.cleanFiles(firstFile, secondFile)
}
10 changes: 7 additions & 3 deletions src/test/e2e/03_temp_directory_deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ func TestTempDirectoryDeploy(t *testing.T) {
t.Log("E2E: Temporary directory deploy")

// run `zarf package deploy` with a specified tmp location
otherTmpPath := "/tmp/othertmp"
var (
otherTmpPath = "/tmp/othertmp"
firstFile = "first-choice-file.txt"
secondFile = "second-choice-file.txt"
)

e2e.setup(t)
defer e2e.teardown(t)

e2e.cleanFiles(otherTmpPath)
e2e.cleanFiles(otherTmpPath, firstFile, secondFile)

path := fmt.Sprintf("build/zarf-package-component-choice-%s.tar.zst", e2e.arch)

Expand All @@ -27,5 +31,5 @@ func TestTempDirectoryDeploy(t *testing.T) {
require.Contains(t, stdErr, otherTmpPath, "The other tmp path should show as being created")
require.NoError(t, err, stdOut, stdErr)

e2e.cleanFiles(otherTmpPath)
e2e.cleanFiles(otherTmpPath, firstFile, secondFile)
}

0 comments on commit f885189

Please sign in to comment.