-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[Azure.Core TestFramework] Fix Required Optional Environment Variable #14906
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,10 +177,6 @@ protected string GetRecordedOptionalVariable(string name, Action<RecordedVariabl | |
|
||
string value = GetOptionalVariable(name); | ||
|
||
var optionsInstance = new RecordedVariableOptions(); | ||
options?.Invoke(optionsInstance); | ||
var sanitizedValue = optionsInstance.Apply(value); | ||
|
||
if (!Mode.HasValue) | ||
{ | ||
return value; | ||
|
@@ -191,6 +187,17 @@ protected string GetRecordedOptionalVariable(string name, Action<RecordedVariabl | |
throw new InvalidOperationException("Recorded value should not be set outside the test method invocation"); | ||
} | ||
|
||
// If the value was populated, sanitize before recording it. | ||
|
||
string sanitizedValue = value; | ||
|
||
if (!string.IsNullOrEmpty(value)) | ||
{ | ||
var optionsInstance = new RecordedVariableOptions(); | ||
options?.Invoke(optionsInstance); | ||
sanitizedValue = optionsInstance.Apply(sanitizedValue); | ||
} | ||
|
||
_recording?.SetVariable(name, sanitizedValue); | ||
return value; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are returning sanitized value here instead of an actual one. That's why tests were on fire. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I just found the tests which I didn't realize were in the other solution and fixed the stupid. |
||
} | ||
|
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.
@pakrym: Based on your feedback on the intent of the options, I reordered things a bit to avoid triggering some code that didn't seem to apply when recording wasn't taking place. Please let me know if I overlooked something and I'll restore the original structure.