Add/improve unit tests for agentendpoint/patch_task.go#936
Add/improve unit tests for agentendpoint/patch_task.go#936ganochenkodg wants to merge 4 commits intoGoogleCloudPlatform:masterfrom
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: ganochenkodg The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @ganochenkodg. Thanks for your PR. I'm waiting for a GoogleCloudPlatform member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
agentendpoint/patch_task_test.go
Outdated
| defer os.RemoveAll(td) | ||
| oldStateFile := taskStateFile | ||
| taskStateFile = filepath.Join(td, "testState") | ||
| defer func() { taskStateFile = oldStateFile }() |
There was a problem hiding this comment.
there are duplicated code statements for preserving task state or to create a temp directory or setting a test client. Can you move them to functions and reuse across tests
With this PR better test coverage for ./agentendpoint/patch_task.go was reached:
github.com/GoogleCloudPlatform/osconfig/agentendpoint/patch_task.go:30: systemRebootRequired 0.0% -> 100.0%
github.com/GoogleCloudPlatform/osconfig/agentendpoint/patch_task.go:64: complete 50.0% -> 100.0%
github.com/GoogleCloudPlatform/osconfig/agentendpoint/patch_task.go:87: setStep 75.0% -> 100.0%
github.com/GoogleCloudPlatform/osconfig/agentendpoint/patch_task.go:95: handleErrorState 66.7% -> 100.0%
github.com/GoogleCloudPlatform/osconfig/agentendpoint/patch_task.go:102: reportFailed 0.0% -> 100.0%
github.com/GoogleCloudPlatform/osconfig/agentendpoint/patch_task.go:117: reportCompletedState 75.0% -> 100.0%
github.com/GoogleCloudPlatform/osconfig/agentendpoint/patch_task.go:130: reportContinuingState 53.8% -> 84.6%
github.com/GoogleCloudPlatform/osconfig/agentendpoint/patch_task.go:159: prePatchReboot 0.0% -> 100.0%
github.com/GoogleCloudPlatform/osconfig/agentendpoint/patch_task.go:163: postPatchReboot 0.0% -> 100.0%
github.com/GoogleCloudPlatform/osconfig/agentendpoint/patch_task.go:167: rebootIfNeeded 0.0% -> 45.7%
github.com/GoogleCloudPlatform/osconfig/agentendpoint/patch_task.go:228: run 38.5% -> 69.2%
Average test coverage for this file 53.68% -> 93.72%