-
Notifications
You must be signed in to change notification settings - Fork 5
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
feat: ability to set value of API_DATA_IS_SENSITIVE to false #915
Conversation
/run pipeline |
/run pipeline |
/run pipeline |
testhelper/tests.go
Outdated
@@ -39,7 +39,10 @@ func (options *TestOptions) TestSetup() { | |||
// testSetup Setup test | |||
func (options *TestOptions) testSetup() { | |||
if !options.SkipTestSetup { | |||
os.Setenv("API_DATA_IS_SENSITIVE", "true") | |||
|
|||
if !options.ApiDataIsNonSensitive { |
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.
@toddgiguere, what do you think? I am not a big fan of the double negative, so I would switch to a pointer-based approach. For example:
type TestOptions struct {
ApiDataIsSensitive *bool
// ...
}
if options.ApiDataIsSensitive == nil {
// Preserve old behavior
os.Setenv("API_DATA_IS_SENSITIVE", "true")
} else {
os.Setenv("API_DATA_IS_SENSITIVE", strconv.FormatBool(*options.ApiDataIsSensitive))
}
That way, leaving ApiDataIsSensitive
as nil
defaults to sensitive (old behavior), and setting it explicitly to true
or false
is straightforward.
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.
I agree, a pointer is probably the only way to go here, if it is not a pointer we have no way of determining if the caller didn't set it at all (took the default) or if they really did want it set to false
. So I agree with the pointer idea.
Let me ask another question though, @ocofaigh I don't know the context of the original ask, but here is my question:
"Is there a legitimate reason why a unit test should EVER want this set to false
"?
If the answer to the above is "maybe not" then another approach would be to check for the presense of this ENV and if it is not present then just set it to true
. Don't even have the option to turn off.
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.
@Vipin654 please go ahead with the suggested pointer-based implementation thanks
/run pipeline |
🎉 This PR is included in version 1.44.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Description
Ability to set API_DATA_IS_SENSITIVE to false so that if terraform detects some output value to be sensitive we can avoid the test failure.
Release required?
x.x.X
)x.X.x
)X.x.x
)Release notes content
Run the pipeline
If the CI pipeline doesn't run when you create the PR, the PR requires a user with GitHub collaborators access to run the pipeline.
Run the CI pipeline when the PR is ready for review and you expect tests to pass. Add a comment to the PR with the following text:
Checklist for reviewers
For mergers