Skip to content

Add unit tests for config/package_resource.go PART 1#1003

Open
bromivipo wants to merge 4 commits into
GoogleCloudPlatform:masterfrom
bromivipo:package_resource
Open

Add unit tests for config/package_resource.go PART 1#1003
bromivipo wants to merge 4 commits into
GoogleCloudPlatform:masterfrom
bromivipo:package_resource

Conversation

@bromivipo

Copy link
Copy Markdown
Contributor

Add unit tests for Validate and Cleanup methods

@google-oss-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: bromivipo
Once this PR has been reviewed and has the lgtm label, please assign paulinakania for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@bromivipo bromivipo changed the title Add unit tests for config/package_resource.go Add unit tests for config/package_resource.go PART 1 Jun 12, 2026
@google-oss-prow

Copy link
Copy Markdown

Hi @bromivipo. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions 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.

OSPolicy_Resource: &agentendpointpb.OSPolicy_Resource{
ResourceType: &agentendpointpb.OSPolicy_Resource_Pkg{Pkg: aptInstalledPR},
},
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe lets move all these setup comands in a separate func, e.g. setupPackageResourceCleanupTest, to increase test readability?

Comment thread config/package_resource_test.go Outdated
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNotFound)
}))
defer server.Close()

@ganochenkodg ganochenkodg Jun 17, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

t.Cleanup(server.Close), in most cases t.Cleanup is most preferable then defer by several reasons

Comment thread config/package_resource_test.go Outdated
wantErr error
}{
{
name: "Apt does not exist, expect error",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: update "expect error" in cases, like "expect apt install error" or "expect 404 error"

@bromivipo bromivipo marked this pull request as ready for review June 18, 2026 09:58
@google-oss-prow google-oss-prow Bot requested a review from burov June 18, 2026 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants