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

Added unit tests for payload file #423

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Jay179-sudo
Copy link

Explanation

Added some basic unit tests for the file that loads the JSON or YAML file provided.

Related issue

#22

Milestone of this PR

/milestone 0.3.0

Checklist

  • I have read the contributing guidelines.
  • I have read the PR documentation guide and followed the process including adding proof manifests to this PR.
  • This is a bug fix and I have added unit tests that prove my fix is effective.
  • This is a feature and I have added CLI tests that are applicable.
  • My PR needs to be cherry picked to a specific release branch which is .

Further Comments

I wanted to add more test cases to the test file.

  • Check whether an error is reported when an invalid JSON or YAML file is provided
  • Check whether the function parses a YAML file properly when two definitions are provided and separated using ---.

As of now, I have used existing payload files from test/commands/scan directory but I could not find payload files that represented the above cases.
Any direction on this?

@Jay179-sudo
Copy link
Author

Hi, @eddycharly. Any updates on this PR?

Copy link

codecov bot commented Jul 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 23.10%. Comparing base (2b6ee12) to head (ae1b36f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #423      +/-   ##
==========================================
+ Coverage   23.04%   23.10%   +0.05%     
==========================================
  Files          85       85              
  Lines        3419     3419              
==========================================
+ Hits          788      790       +2     
+ Misses       2552     2550       -2     
  Partials       79       79              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@eddycharly
Copy link
Member

Thanks, we should validate the data too.

@Jay179-sudo
Copy link
Author

Since the data type returned is an empty interface, can we or should we validate the data coming out from this function?

I did some digging around and I could not come up with a solution that involves adding new data to the test cases and validating it within the test. How would we add the want data in the test case without calling the load function itself? I am a little stumped on this.

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