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: added missing tests for the CronJob analyzer #1019

Merged
merged 2 commits into from
Mar 21, 2024

Conversation

VaibhavMalik4187
Copy link
Contributor

📑 Description

  • Fixed a small bug where pre-analysis was incorrectly appended to the results every time at the end of the for loop. This caused the result for a single cronjob failure to be appended multiple times in the final results.

  • Added missing test cases to ensure proper testing of the CronJob analyzer. The addition of these missing test cases has increased the code coverage of this analyzer to over 96%.

Partially Addresses: #889

✅ Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed

@VaibhavMalik4187 VaibhavMalik4187 requested review from a team as code owners March 16, 2024 06:22
Copy link
Contributor

@JuHyung-Son JuHyung-Son left a comment

Choose a reason for hiding this comment

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

nice catch.

just one question.
i guess comparing failureText can occur unexpected test fail in the future even code is right.
how do you think?

pkg/analyzer/cronjob_test.go Outdated Show resolved Hide resolved
@VaibhavMalik4187
Copy link
Contributor Author

nice catch.

just one question. i guess comparing failureText can occur unexpected test fail in the future even code is right. how do you think?

Thanks,

Great question. I think you're right, there's a possibility of the failure text changing in the future and when that happens the test will break even though it shouldn't.

I've compared failureText in tests for others analyzers as well. Looks like now would be a great time to update them as well. Thought?

- Fixed a small bug where pre-analysis was incorrectly appended to the
  results every time at the end of the for loop. This caused the result
  for a single cronjob failure to be appended multiple times in the
  final results.

- Added missing test cases to ensure proper testing of the CronJob
  analyzer. The addition of these missing test cases has increased the
  code coverage of this analyzer to over 96%.

Partially Addresses: k8sgpt-ai#889

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
It is possible that the error or failure strings might change in the
future, causing the tests to fail. This commit addresses that issue by
removing the matching of failure text from various analyzer tests.

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
Copy link

codecov bot commented Mar 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.24%. Comparing base (ebfbba9) to head (f426be7).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1019      +/-   ##
==========================================
+ Coverage   65.71%   67.24%   +1.53%     
==========================================
  Files          30       30              
  Lines        2549     2549              
==========================================
+ Hits         1675     1714      +39     
+ Misses        827      791      -36     
+ Partials       47       44       -3     

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

@JuHyung-Son
Copy link
Contributor

nice catch.
just one question. i guess comparing failureText can occur unexpected test fail in the future even code is right. how do you think?

Thanks,

Great question. I think you're right, there's a possibility of the failure text changing in the future and when that happens the test will break even though it shouldn't.

I've compared failureText in tests for others analyzers as well. Looks like now would be a great time to update them as well. Thought?

yes. it needs to be. but not urgent. feel free to do that.

Copy link
Contributor

@JuHyung-Son JuHyung-Son left a comment

Choose a reason for hiding this comment

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

much better.

thanks for stable tests.

@AlexsJones AlexsJones merged commit 3c1c055 into k8sgpt-ai:main Mar 21, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants