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

test: set dummy value for NUGET_PACKAGES #8107

Merged
merged 2 commits into from
Dec 16, 2024

Conversation

nikpivkin
Copy link
Contributor

Description

Tests for nuget may fail if the packages used in the tests are located on the developer's machine in the ~/.nuget/packages or NUGET_PACKAGES directory, since the analyser uses this directory to search for licenses:

--- FAIL: TestRepository (8.14s)
    --- FAIL: TestRepository/nuget (0.01s)
        /Users/nikita/projects/trivy/integration/integration_test.go:304: 
...
            	            	-     Licenses: ([]string) <nil>,
            	            	+     Licenses: ([]string) (len=1) {
            	            	+      (string) (len=3) "MIT"
            	            	+     },
...

This PR sets a dummy value for the NUGET_PACKAGES environment variable.

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

@nikpivkin nikpivkin changed the title fix(test): set dummy value for NUGET_PACKAGES test: set dummy value for NUGET_PACKAGES Dec 16, 2024
@nikpivkin nikpivkin marked this pull request as ready for review December 16, 2024 10:55
@nikpivkin nikpivkin requested a review from knqyf263 as a code owner December 16, 2024 10:55
Copy link
Collaborator

@knqyf263 knqyf263 left a comment

Choose a reason for hiding this comment

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

LGTM. Left a small comment.

@@ -16,6 +16,7 @@ import (

// TestRepository tests `trivy repo` with the local code repositories
func TestRepository(t *testing.T) {
t.Setenv("NUGET_PACKAGES", "/tmp/fake_nuget_packages")
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if using t.TempDir?

Suggested change
t.Setenv("NUGET_PACKAGES", "/tmp/fake_nuget_packages")
t.Setenv("NUGET_PACKAGES", t.TempDir())

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. Fixed 26fb4f9

@knqyf263 knqyf263 added this pull request to the merge queue Dec 16, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 16, 2024
@knqyf263 knqyf263 added this pull request to the merge queue Dec 16, 2024
Merged via the queue into aquasecurity:main with commit 17827db Dec 16, 2024
12 checks passed
@nikpivkin nikpivkin deleted the nuget-repo-test branch December 16, 2024 13:55
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.

2 participants