Skip to content

Conversation

@troy0820
Copy link
Member

@troy0820 troy0820 commented Jun 9, 2023

What does this change

  • Add tests for method renamePluginVolume
  • Fixes linter nits

What issue does it fix

No issue to close but improves the testing posture of this controller.

Notes for the reviewer

During adding these tests, there is a condition I believe we are not checking for. If the list of PVCs returned length is < 1 we still continue to return the readyPVC, tempPVC, nil (r.getExistingPluginPVCs(...)). There is a no-op check there for the items list but we are returning:

   return readyPVC, tempPVC, nil

even if the list (which doesn't error, because you can return an empty list) results.Items < 1. Not sure what behavior we want from this but guarding against that was noted during testing this method. If we do want to make sure that we always get a list > 1 from that method, I can update this PR to modify that.

Checklist

  • Did you write tests?
  • Did you write documentation?
    • No, it's not needed for adding tests
  • Did you make any API changes? Update the corresponding API documentation.
    • No, no changes to the API was made

@troy0820 troy0820 force-pushed the troy0820/add-tests branch 3 times, most recently from 84811a5 to 10f2d45 Compare June 13, 2023 21:21
@sgettys
Copy link
Collaborator

sgettys commented Jun 14, 2023

In the scenario you noted yes we can get a list of 0 which will result in the tempPVC and readyPVC both being returned as nil. I wouldn't have any issue with putting a guard check in there as that won't change the behavior of the function at all but it will make it more explicit.

@troy0820 troy0820 force-pushed the troy0820/add-tests branch from c4f0e27 to 03aafce Compare June 16, 2023 16:34
@troy0820 troy0820 force-pushed the troy0820/add-tests branch from 03aafce to 1ad8566 Compare June 23, 2023 18:14
@codecov
Copy link

codecov bot commented Jun 27, 2023

Codecov Report

Merging #211 (06f69e2) into main (37ed573) will increase coverage by 0.25%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #211      +/-   ##
==========================================
+ Coverage   76.67%   76.92%   +0.25%     
==========================================
  Files          13       13              
  Lines        1556     1556              
==========================================
+ Hits         1193     1197       +4     
+ Misses        230      228       -2     
+ Partials      133      131       -2     
Flag Coverage Δ
unit-tests 76.92% <100.00%> (+0.25%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
controllers/agentconfig_controller.go 73.36% <100.00%> (+0.96%) ⬆️

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

troy0820 added 3 commits July 6, 2023 15:50
Signed-off-by: Troy Connor <[email protected]>
@troy0820 troy0820 force-pushed the troy0820/add-tests branch from 06f69e2 to 52d63d5 Compare July 6, 2023 19:51
@schristoff schristoff merged commit 459da6d into getporter:main Jul 7, 2023
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.

3 participants