cve-bin-tool icon indicating copy to clipboard operation
cve-bin-tool copied to clipboard

test: regression tests for unset data

Open terriko opened this issue 1 year ago • 4 comments

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 avatar Sep 13 '24 16:09 terriko

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).

terriko avatar Sep 30 '24 17:09 terriko

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

Malay-dev avatar Oct 03 '24 14:10 Malay-dev

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

terriko avatar Oct 14 '24 17:10 terriko

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 avatar Oct 14 '24 17:10 Malay-dev

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?

Malay-dev avatar Oct 21 '24 16:10 Malay-dev

Hey! Is anyone still working on this issue? Do let me know if any help is needed!

JigyasuRajput avatar Feb 08 '25 05:02 JigyasuRajput