kubebb / core

A declarative component lifecycle management platform
https://kubebb.github.io/website
Apache License 2.0
8 stars 9 forks source link

chore: add test cases for componentplan.go #220

Closed Henry-Gao-2004 closed 1 year ago

Henry-Gao-2004 commented 1 year ago

What type of PR is this?

What this PR does / why we need it

Which issue(s) this PR fixes

For #194

Special notes for your reviewer

codecov[bot] commented 1 year ago

Codecov Report

Merging #220 (04ed090) into main (8fc66c5) will increase coverage by 1.91%. The diff coverage is 57.14%.

@@            Coverage Diff             @@
##             main     #220      +/-   ##
==========================================
+ Coverage   16.24%   18.16%   +1.91%     
==========================================
  Files          32       32              
  Lines        3023     3023              
==========================================
+ Hits          491      549      +58     
+ Misses       2501     2443      -58     
  Partials       31       31              
Files Changed Coverage Δ
controllers/componentplan_controller.go 0.00% <0.00%> (ø)
api/v1alpha1/componentplan.go 43.28% <100.00%> (+43.28%) :arrow_up:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

Henry-Gao-2004 commented 1 year ago

It seems like any function involving a condition with LastTransitionTime cannot be tested, as it is impossible to generate an expected condition (because LastTransitionTime uses metav1.Now()). Can I know if there is a way to test those methods, or should we just leave them untested?

0xff-dev commented 1 year ago

It seems like any function involving a condition with LastTransitionTime cannot be tested, as it is impossible to generate an expected condition (because LastTransitionTime uses metav1.Now()). Can I know if there is a way to test those methods, or should we just leave them untested?

I think you can ignore the comparison of the LastTransitionTime field. This test function has the same problem as you. I am also ignoring the comparison of the time field.

https://github.com/kubebb/core/blob/2b6df16e695115c6820db52120bdeffe265187cd/api/v1alpha1/subscription_test.go#L38

Henry-Gao-2004 commented 1 year ago

I think you can ignore the comparison of the LastTransitionTime field. This test function has the same problem as you. I am also ignoring the comparison of the time field.

https://github.com/kubebb/core/blob/2b6df16e695115c6820db52120bdeffe265187cd/api/v1alpha1/subscription_test.go#L38

Great idea! I will write the test cases for all functions in componentplan.go and then be ready for review again! Thank you very much for your suggestion!

Henry-Gao-2004 commented 1 year ago

The branch is now up to date!