malcontent
malcontent copied to clipboard
Add tests for new archive functionality
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, andzipextraction functions - Verifying that nested archive extraction produces the expected result
- Whether a scan of a nested archive works (in this case a
.tar.gzwith a.tar.gzfile 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