fix: isolate test environment from external variables#613
Conversation
…iables in tests and use it across test suites
…iables in tests and use it across test suites
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This comment has been minimized.
This comment has been minimized.
| func IsolateEnvironmentForTest(t *testing.T, keys ...string) { | ||
| t.Helper() | ||
| toClear := keys | ||
| if len(toClear) == 0 { | ||
| toClear = KnownLeakEnvironmentKeys | ||
| } |
There was a problem hiding this comment.
Should we ALWAYS consider ignoring the KnownLeakEnvironmentKeys values?
If so, we should concat always.
In the current way, if parameters for keys are passed, the KnownLeakEnvironmentKeys are not being considered
There was a problem hiding this comment.
this behavior has been documented in my last commit
b4853bd to
30ab48f
Compare
This comment has been minimized.
This comment has been minimized.
PR Reviewer Guide 🔍
|
Description
This PR adds an extendable mechanism to ignore environment variables in unit tests.
Checklist
make test)make generate)make lint)go get github.com/snyk/go-application-framework@YOUR_LATEST_GAF_COMMITin thecliv2directory.go.modto point to your local GAF code.go mod tidyin thecliv2directory.go.modandgo.sumchanges.