Skip to content

Commit 3923a2c

Browse files
author
Pete Emerson
committed
Check file count on file extraction
1 parent 4b41500 commit 3923a2c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

file_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,12 +355,18 @@ func TestExtractFilesExtractFile(t *testing.T) {
355355
zipFilePath := "test-fixtures/fetch-test-public-0.0.4.zip"
356356
filePathToExtract := "zzz.txt"
357357
localFileName := "/localzzz.txt"
358+
expectedFileCount := 1
358359
localPathName := filepath.Join(tempDir, localFileName)
359-
_, err = extractFiles(zipFilePath, filePathToExtract, localPathName)
360+
fileCount, err := extractFiles(zipFilePath, filePathToExtract, localPathName)
361+
360362
if err != nil {
361363
t.Fatalf("Failed to extract files: %s", err)
362364
}
363365

366+
if fileCount != expectedFileCount {
367+
t.Fatalf("Expected to extract %d files, extracted %d instead", expectedFileCount, fileCount)
368+
}
369+
364370
filepath.Walk(tempDir, func(path string, info os.FileInfo, err error) error {
365371
relativeFilename := strings.TrimPrefix(path, tempDir)
366372

0 commit comments

Comments
 (0)