Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for new functionality #215

Merged
merged 14 commits into from May 17, 2024
Merged

Conversation

egibs
Copy link
Collaborator

@egibs egibs commented May 11, 2024

A lot of new functionality has been added recently 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)
  • The functionality of OCI image scanning

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

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

$ go test -timeout 30s -coverprofile=/var/folders/3g/88131l9j11x995ppjbxsvhbh0000gn/T/vscode-goHMiJhQ/go-code-cover github.com/chainguard-dev/bincapz/pkg/action

ok  	github.com/chainguard-dev/bincapz/pkg/action	6.489s	coverage: 57.9% of statements

This PR also adds a small test for the new profiling feature.

@egibs egibs requested a review from tstromberg May 11, 2024 02:18
@egibs egibs changed the title Add tests for new archive functionality Add tests for new functionality May 11, 2024
}

var out bytes.Buffer
md, err := render.New("markdown", &out)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change this to use the simple renderer? The output is more stable and lower maintenance for tests that don't require markdown specific testing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in: 3b11939 (#215).

pkg/render/simple.go Outdated Show resolved Hide resolved
@egibs egibs requested a review from tstromberg May 13, 2024 20:15
@egibs egibs requested a review from vaikas May 14, 2024 13:10
@tstromberg tstromberg merged commit 996ba4c into chainguard-dev:main May 17, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants