litmuschaos / chaos-operator

chaos engineering via kubernetes operator
Apache License 2.0
134 stars 93 forks source link

add the demo unit testing in the chaos repo #466

Closed prajak002 closed 1 year ago

prajak002 commented 1 year ago

have added the package unit_tests declaration to the top of the file. I have imported the testing and chaos-operator/chaos_operator packages. I have renamed the ChaosOperator function to TestChaosOperator. I have added a t *testing.T parameter to the TestChaosOperator function. I have added a defer operator.Stop() statement to the end of the TestChaosOperator function. I have added a if experiment.Status != chaos_experiment.StatusCompleted statement to the end of the TestChaosOperator function and asserted that the value of experiment.Status is equal to chaos_experiment.StatusCompleted.

What this PR does / why we need it:

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #

Special notes for your reviewer:

Checklist:

prajak002 commented 1 year ago

add the sample in which way we can do unit testing