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: regression tests for unset data #4441

Open
terriko opened this issue Sep 13, 2024 · 5 comments
Open

test: regression tests for unset data #4441

terriko opened this issue Sep 13, 2024 · 5 comments
Assignees
Labels
good first issue Good for newcomers hacktoberfest good issue for hacktoberfest participation

Comments

@terriko
Copy link
Contributor

terriko commented Sep 13, 2024

The bug in #4438 happened because of an unset serial number, and a fix is in progress in #4440

What I'd like is some improved tests for unset data in output_engine so this doesn't happen again, so I want a test that tries to run output_engine/__init__.py with various values not set.

I have a feeling that any test that cycles through all the possible fields will right now find a few bugs, so we may want to start with just sbom_serial_number but design it so that we can have a parameter test with any given field unset so eventually all possible fields will be tested.

@terriko terriko added good first issue Good for newcomers hacktoberfest good issue for hacktoberfest participation labels Sep 30, 2024
@terriko
Copy link
Contributor Author

terriko commented Sep 30, 2024

This may require some reading to make sure you understand how to use pytest and how to call the correct code, but I think it should be beginner-friendly so I'm tagging it as a "good first issue" and will put the new contributor tips below. I'm also tagging it for hacktoberfest. If you're interested in doing this as part of the contest, make sure you do it within their timeframe and follow their rules. (Most notably: don't create the PR before October 1 or it won't count)

Short tips for new contributors:

  • cve-bin-tool's contributor docs
  • If you've contributed to open source but not this project, you might just want our checklist for a great pull request
  • cve-bin-tool uses https://www.conventionalcommits.org/ style for commit messages, and we have a test that checks the title of your pull request (PR). A good potential title for this one is in the title of this issue.
  • You can make an issue auto close by including a comment "fixes #ISSUENUMBER" in your PR comments where ISSUENUMBER is the actual number of the issue. This "links" the issue to the pull request.

Claiming issues:

  • You do not need to have an issue assigned to you before you work on it. To "claim" an issue either make a linked pull request or comment on the issue saying you'll be working on it.
  • If someone else has already commented or opened a pull request, assume it is claimed and find another issue to work on.
  • If it's been more than 1 week without progress, you can ask in a comment if the claimant is still working on it before claiming it yourself (give them at least 3 days to respond before assuming they have moved on).

@Malay-dev
Copy link
Contributor

Hey... I would like to work on this issue...

@terriko
Copy link
Contributor Author

terriko commented Oct 14, 2024

@Malay-dev Are you still working on this? Did you need some help?

@Malay-dev
Copy link
Contributor

Malay-dev commented Oct 14, 2024

yep... I am still figuring out the pytest docs

def test_unset_sbom_serial_number(self):
        # Create a test case with sbom_serial_number unset
        test_data = {
            # Other required fields...
            "sbom_serial_number": None
        }

        # Attempt to run output_engine_init with the test data
        with self.assertRaises(Exception):  # Adjust the exception type as needed
            output_engine_init(**test_data)

@Malay-dev
Copy link
Contributor

Malay-dev commented Oct 21, 2024

Hey @terriko Can you give some more guidance such as where I should make this test file and how can I test it after writing the test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers hacktoberfest good issue for hacktoberfest participation
Projects
None yet
Development

No branches or pull requests

2 participants