malcontent icon indicating copy to clipboard operation
malcontent copied to clipboard

Add tests for new archive functionality

Open egibs opened this issue 1 year ago • 0 comments

A lot of new functionality has been added around archives and the testing gaps were piling up. This PR covers a decent bit of the newly-added functionality by testing the following cases:

  • Verifying that the correct extraction function is used based on file extension
  • The functionality of the tar, gzip, and zip extraction functions
  • Verifying that nested archive extraction produces the expected result
  • Whether a scan of a nested archive works (in this case a .tar.gz with a .tar.gz file inside of it

To support these test cases, I uploaded archives for each portion of the functionality and an output file with the expected scan results when testing that.

All of the new tests are passing locally and should in CI as well:

$ go test -timeout 30s -run ^(TestExtractionMethod|TestExtractionMultiple|TestExtractTar|TestExtractGzip|TestExtractZip|TestExtractNestedArchive|TestScanArchive)$ github.com/chainguard-dev/bincapz/pkg/action

ok  	github.com/chainguard-dev/bincapz/pkg/action	6.048s

egibs avatar May 11 '24 02:05 egibs