Conversation
|
Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement Learn more about why HashiCorp requires a CLA and what the CLA includes Have you signed the CLA already but the status is still pending? Recheck it. |
There was a problem hiding this comment.
Thank you so much for updating the tests - they were in dire need of some love! I'm not sure I see the utility in using gomock or a test suite in this specific case though. Do you think you could try refactoring the tests so that they use the basic Go test setup (e.g. TestFoo(t *testing.T) and t.Run for sub tests), so we can compare? I'd also appreciate if you could separate the changes into separate commits, so I can view:
- Just the dependency upgrade (with any changes to existing tests required). This can also include the module version bump
- Just the test changes
I love the new tests but I don't know if we need the suite or gomock integration. What do you think?
b7302d0 to
a75e09f
Compare
Yeah I'll split them out into a couple commits to see the difference. I don't think gomock is necessary here since we already have mocks created and we don't use thorough enough DI to get the benefits. I do think the suite pattern here is my hill to die on, though. Once I split out the commits, it'll be crystal clear how much clarity it's providing here, but I have another example in the meantime from another module I'm working on: https://github.com/hashicorp/go-secure-stdlib/blob/main/awsutil/generate_credentials_test.go#L232. Take a look at the suite I wrote out in this PR and then compare it against the
|
3217a18 to
ffca6ce
Compare
Instead of using a test suite, use vanilla require and assert packages for assertions and standard library testing patterns for tests and sub tests.
johanbrandhorst
left a comment
There was a problem hiding this comment.
Thanks, just a minor comment!
Co-authored-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
|
@jimlambrt @sgmiller this follows on some work Emilia did in go-secure-stdlib (hashicorp/go-secure-stdlib#169) to move our usage of AWS Go SDK away from V1 as it is EOL now. |
| testEncryptionRoundTrip(t, s) | ||
| func TestEncryptAndDecrypt(t *testing.T) { | ||
| t.Run("Success - mock client", func(t *testing.T) { | ||
| // Works around lack of AWS_REGION var in CI |
This PR updates awsutil to use aws-sdk-go-v2 because v1 has gone EOL. This is also part of addressing ICU-17267.
It required an API breaking change, so I bumped the mod version to v3. Not sure if this is the correct way to do it here (does this remove v2?)
I also refactored the tests into a suite pattern as a demo. This is a particularly good spot to use the suite pattern because the code only gets touched once in a blue moon, so encoding as much understanding about how the code should function directly into tests will help the next person two years from now.
PCI review checklist
I have documented a clear reason for, and description of, the change I am making.
If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.
If applicable, I've documented the impact of any changes to security controls.
Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.