-
Notifications
You must be signed in to change notification settings - Fork 9.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests: Remove numeric constants #39840
Conversation
Community NoteVoting for Prioritization
For Submitters
|
b8969bc
to
8215189
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bless you! 🙏 @ewbankkit |
See #39881 for fixes for open PRs related to this change. |
This functionality has been released in v5.74.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
Description
tl;dr
acctest.Ct1
).acctest.Ct12Digit = "123456789012"
for test AWS account numbers.make fix-constants
).gofmt
andgoimports
on generated Go code.WriteTemplate()
toBufferTemplate()
to clarify memory vs. disk writing.Key Changes:
Constants for numeric string literals in tests did not provide the benefits hoped and made the code more difficult to read. They are being removed, with a constant
12345678901
being added.Example:
Previously, we relied on
go/format.Source
to format Go code we generate. However,go/format
package includes this warning:The pull request also improves the functionality of Go generators by expanding the formatting steps applied after code generation. Now, after the full composition of the generated Go files, both gofmt and goimports are automatically executed. These tools ensure:
This provides several benefits:
Example:
Refactoring of Generator Functions: Clarification of Roles
A key refactor has been made to clarify the distinction between buffering data during the generation process and writing data to the final destination (such as files). The following changes have been introduced:
WriteBytes()
,WriteTemplate()
, andWriteTemplateSet()
have been renamed to:BufferBytes()
BufferTemplate()
BufferTemplateSet()
These new function names better reflect their actual purpose: they buffer the generated content rather than directly writing it to a file. This change enhances code clarity by reducing potential confusion between buffering and writing operations, which are distinctly different phases in the generation process.
Write()
: TheWrite()
function remains unchanged, as it correctly describes its role of finalizing the process by actually writing the buffered data to the intended output destination (typically a file).Example:
Benefits:
Relations
Closes #0000
References
Output from Acceptance Testing