Add unit tests for policies/apt.go PART 3#951
Add unit tests for policies/apt.go PART 3#951ganochenkodg 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. |
|
|
||
| // TestAptChanges tests the aptChanges function, ensuring it correctly handles package installations, removals, and updates. | ||
| func TestAptChanges(t *testing.T) { | ||
| dpkgQueryArgs := []string{"-W", "-f", `\{"architecture":"${Architecture}","package":"${Package}","source_name":"${source:Package}","source_version":"${source:Version}","status":"${db:Status-Status}","version":"${Version}"\}` + "\n"} |
There was a problem hiding this comment.
Why don't we use existing variable ?https://github.com/GoogleCloudPlatform/osconfig/blob/master/packages/apt_deb.go#L48C2-L48C15
There was a problem hiding this comment.
because we try to avoid changing the original code. they are placed in different package ("packages", not "policies") and start from small letters -> can't be imported without renaming. Should we update apt_deb.go?
| // TestAptChanges tests the aptChanges function, ensuring it correctly handles package installations, removals, and updates. | ||
| func TestAptChanges(t *testing.T) { | ||
| dpkgQueryArgs := []string{"-W", "-f", `\{"architecture":"${Architecture}","package":"${Package}","source_name":"${source:Package}","source_version":"${source:Version}","status":"${db:Status-Status}","version":"${Version}"\}` + "\n"} | ||
| aptUpgradableArgs := []string{"--just-print", "-qq", "dist-upgrade"} |
| name: "no changes needed", | ||
| }, | ||
| { | ||
| name: "failed to get installed packages", |
There was a problem hiding this comment.
Please name cases in the format "intput, expected result"
!!! Merge and review only after PR 949
Depends on expectedCommand and setExpectations from policies/policies_test.go
New test coverage:
github.com/GoogleCloudPlatform/osconfig/policies/apt.go:195: aptChanges 98.1%