Skip to content

Add unit tests for repository_resource.go#1002

Open
bromivipo wants to merge 6 commits into
GoogleCloudPlatform:masterfrom
bromivipo:repository_resource
Open

Add unit tests for repository_resource.go#1002
bromivipo wants to merge 6 commits into
GoogleCloudPlatform:masterfrom
bromivipo:repository_resource

Conversation

@bromivipo

@bromivipo bromivipo commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

This PR contains unit tests for repository_resource.go

@google-oss-prow google-oss-prow Bot requested review from burov and savija-tv June 11, 2026 12:33
@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.

Comment thread config/repository_resource_test.go Outdated
utiltest.AssertEquals(t, aptRepo != nil, true)
utiltest.AssertEquals(t, aptRepo.GpgFilePath != "", true)
utiltest.AssertEquals(t, aptRepo.GpgChecksum != "", true)
utiltest.AssertEquals(t, len(aptRepo.GpgFileContents) > 0, true)

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.

Is it possible to compare this with some expected values?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if hardcoding an expected value for FileContents is the best approach here:

  • Hardcoding it will cause the test to fail if the GPG key changes externally. I'm not sure that it is static.
  • Fetching the key during the test just to compare it with what Validate downloaded feels redundant, and the same applies to creating a direct mock of that behavior.

Instead, I've added a check to verify the dependency between FileContents, Checksum, and Path.

dir := t.TempDir()
repoPath := filepath.Join(dir, "repo")
gpgPath := filepath.Join(dir, "key.gpg")
os.WriteFile(repoPath, []byte("repo contents"), 0644)

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.

you can probably move these 4 lines out of setup

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@google-oss-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: bromivipo, iliatsuprik
Once this PR has been reviewed and has the lgtm label, please assign zoltak-g 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

@google-oss-prow google-oss-prow Bot removed the lgtm label Jun 11, 2026
@google-oss-prow

Copy link
Copy Markdown

New changes are detected. LGTM label has been removed.

@bromivipo bromivipo marked this pull request as ready for review June 11, 2026 15:59
@bromivipo bromivipo requested a review from iliatsuprik June 11, 2026 15:59
@google-oss-prow google-oss-prow Bot requested a review from paulinakania June 11, 2026 15:59
@bromivipo bromivipo force-pushed the repository_resource branch from b98ded0 to 5fe4d60 Compare July 1, 2026 13:56
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