Skip to content

Commit

Permalink
Check file count on file extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
Pete Emerson committed Oct 26, 2020
1 parent 4b41500 commit 3923a2c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,18 @@ func TestExtractFilesExtractFile(t *testing.T) {
zipFilePath := "test-fixtures/fetch-test-public-0.0.4.zip"
filePathToExtract := "zzz.txt"
localFileName := "/localzzz.txt"
expectedFileCount := 1
localPathName := filepath.Join(tempDir, localFileName)
_, err = extractFiles(zipFilePath, filePathToExtract, localPathName)
fileCount, err := extractFiles(zipFilePath, filePathToExtract, localPathName)

if err != nil {
t.Fatalf("Failed to extract files: %s", err)
}

if fileCount != expectedFileCount {
t.Fatalf("Expected to extract %d files, extracted %d instead", expectedFileCount, fileCount)
}

filepath.Walk(tempDir, func(path string, info os.FileInfo, err error) error {
relativeFilename := strings.TrimPrefix(path, tempDir)

Expand Down

0 comments on commit 3923a2c

Please sign in to comment.