Add unit tests for ospatch_apt_upgrade.go#938
Add unit tests for ospatch_apt_upgrade.go#938ganochenkodg wants to merge 5 commits intoGoogleCloudPlatform:masterfrom
Conversation
|
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. |
ospatch/apt_upgrade_test.go
Outdated
| wantErr error | ||
| }{ | ||
| { | ||
| name: "Success", |
There was a problem hiding this comment.
Could you change names of the test cases to make it more readable.
Don't use camel case and add a bit more details on what this testcase is actually testing, what is expected result of the testcase.
There was a problem hiding this comment.
Will rename cases then. Sometimes i see CamelCase test names so I thought it's allowed, e.g. https://github.com/GoogleCloudPlatform/osconfig/blob/master/packages/apt_deb_test.go#L955-L961
|
/gcbrun |
|
/gcbrun |
1 similar comment
|
/gcbrun |
|
New changes are detected. LGTM label has been removed. |
1 similar comment
|
New changes are detected. LGTM label has been removed. |
|
[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 |
1 similar comment
|
[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 |
|
/gcbrun |
ospatch/apt_upgrade_test.go
Outdated
| gomock.InOrder( | ||
| mockCommandRunner.EXPECT().Run(gomock.Any(), utilmocks.EqCmd(updateCmd)).Return(stdout, empty, nil), | ||
| mockCommandRunner.EXPECT().Run(gomock.Any(), utilmocks.EqCmd(upgradeCmd)).Return(pkg1out, empty, nil), | ||
| mockCommandRunner.EXPECT().Run(gomock.Any(), utilmocks.EqCmd(installPkg1Cmd)).Return(stdout, empty, nil), |
There was a problem hiding this comment.
I think inlining of the variables updateCmd, upgradeCmd and installPkg1Cmd might benefit readability of the test cases, as well stdout variable should be renamed to fakeOutput or something similar to signal that this output is rather stub.
ospatch/apt_upgrade_test.go
Outdated
| gomock.InOrder( | ||
| mockCommandRunner.EXPECT().Run(gomock.Any(), utilmocks.EqCmd(updateCmd)).Return(stdout, empty, nil), |
There was a problem hiding this comment.
Same, inlining of updateCmd and upgradeCmd will benefit readability of the testcase
With this PR better test coverage for ./ospatch/apt_upgrade.go was reached:
github.com/GoogleCloudPlatform/osconfig/ospatch/apt_upgrade.go:36: AptGetUpgradeType 0.0% -> 100.0%
github.com/GoogleCloudPlatform/osconfig/ospatch/apt_upgrade.go:43: AptGetExcludes 0.0% -> 100.0%
github.com/GoogleCloudPlatform/osconfig/ospatch/apt_upgrade.go:50: AptGetExclusivePackages 0.0% -> 100.0%
github.com/GoogleCloudPlatform/osconfig/ospatch/apt_upgrade.go:57: AptGetDryRun 0.0% -> 100.0%
github.com/GoogleCloudPlatform/osconfig/ospatch/apt_upgrade.go:64: RunAptGetUpgrade 0.0% -> 100.0%