Add unit tests for repository_resource.go#1002
Conversation
|
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 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. |
| 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) |
There was a problem hiding this comment.
Is it possible to compare this with some expected values?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
you can probably move these 4 lines out of setup
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: bromivipo, iliatsuprik 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 |
|
New changes are detected. LGTM label has been removed. |
b98ded0 to
5fe4d60
Compare
This PR contains unit tests for repository_resource.go