Skip to content

Commit

Permalink
Remove zip files that were generated as a result of a test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Ip committed Jan 11, 2023
1 parent 086feef commit 99b4877
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions internal/provider/zip_archiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
func TestZipArchiver_Content(t *testing.T) {
zipfilepath := "archive-content.zip"
archiver := NewZipArchiver(zipfilepath)
defer os.Remove(zipfilepath)
if err := archiver.ArchiveContent([]byte("This is some content"), "content.txt"); err != nil {
t.Fatalf("unexpected error: %s", err)
}
Expand All @@ -26,6 +27,7 @@ func TestZipArchiver_Content(t *testing.T) {
func TestZipArchiver_File(t *testing.T) {
zipfilepath := "archive-file.zip"
archiver := NewZipArchiver(zipfilepath)
defer os.Remove(zipfilepath)
if err := archiver.ArchiveFile("./test-fixtures/test-file.txt"); err != nil {
t.Fatalf("unexpected error: %s", err)
}
Expand All @@ -48,13 +50,16 @@ func TestZipArchiver_FileMode(t *testing.T) {

stringArray := [5]string{"0444", "0644", "0666", "0744", "0777"}
for _, element := range stringArray {
archiver := NewZipArchiver(zipFilePath)
archiver.SetOutputFileMode(element)
if err := archiver.ArchiveFile(toZipPath); err != nil {
t.Fatalf("unexpected error: %s", err)
}
func() {
archiver := NewZipArchiver(zipFilePath)
defer os.Remove(zipFilePath)
archiver.SetOutputFileMode(element)
if err := archiver.ArchiveFile(toZipPath); err != nil {
t.Fatalf("unexpected error: %s", err)
}

ensureFileMode(t, zipFilePath, element)
ensureFileMode(t, zipFilePath, element)
}()
}
}

Expand All @@ -72,6 +77,7 @@ func TestZipArchiver_FileModified(t *testing.T) {
}

zip()
defer os.Remove(zipFilePath)

expectedContents, err := ioutil.ReadFile(zipFilePath)
if err != nil {
Expand Down Expand Up @@ -99,6 +105,7 @@ func TestZipArchiver_FileModified(t *testing.T) {
func TestZipArchiver_Dir(t *testing.T) {
zipfilepath := "archive-dir.zip"
archiver := NewZipArchiver(zipfilepath)
defer os.Remove(zipfilepath)
if err := archiver.ArchiveDir("./test-fixtures/test-dir", []string{""}); err != nil {
t.Fatalf("unexpected error: %s", err)
}
Expand All @@ -113,6 +120,7 @@ func TestZipArchiver_Dir(t *testing.T) {
func TestZipArchiver_Dir_Exclude(t *testing.T) {
zipfilepath := "archive-dir.zip"
archiver := NewZipArchiver(zipfilepath)
defer os.Remove(zipfilepath)
if err := archiver.ArchiveDir("./test-fixtures/test-dir", []string{"file2.txt"}); err != nil {
t.Fatalf("unexpected error: %s", err)
}
Expand All @@ -126,6 +134,7 @@ func TestZipArchiver_Dir_Exclude(t *testing.T) {
func TestZipArchiver_Dir_Exclude_With_Directory(t *testing.T) {
zipfilepath := "archive-dir.zip"
archiver := NewZipArchiver(zipfilepath)
defer os.Remove(zipfilepath)
if err := archiver.ArchiveDir("./test-fixtures/", []string{"test-dir", "test-dir2/file2.txt"}); err != nil {
t.Fatalf("unexpected error: %s", err)
}
Expand All @@ -146,6 +155,7 @@ func TestZipArchiver_Multiple(t *testing.T) {
}

archiver := NewZipArchiver(zipfilepath)
defer os.Remove(zipfilepath)
if err := archiver.ArchiveMultiple(content); err != nil {
t.Fatalf("unexpected error: %s", err)
}
Expand Down

0 comments on commit 99b4877

Please sign in to comment.