Skip to content

Commit af76566

Browse files
authored
Fix OTel test env var reset logic (#1066)
1 parent af20e8e commit af76566

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

test/Unit/OpenTelemetry/OpenTelemetryControllerTests.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ namespace Microsoft.Azure.Functions.PowerShellWorker.Test.OpenTelemetry
1010
{
1111
using PowerShell = System.Management.Automation.PowerShell;
1212

13+
[Collection("Sequence")]
1314
public class OpenTelemetryControllerTests
1415
{
1516
// These constant values will work because they are not actually passed to the module
1617
// The module would fail with these inputs, it needs real invocation id and trace information
1718
private const string FakeInvocationID = "Fake InvocationID";
1819
private const string FakeTraceParent = "Fake TraceParent";
1920

21+
private const string OTelEnabledEnvironmentVariableName = "OTEL_FUNCTIONS_WORKER_ENABLED";
2022
private readonly Mock<ILogger> _mockLogger = new Mock<ILogger>(MockBehavior.Strict);
2123
private readonly Mock<IPowerShellServicesForOpenTelemetry> _mockOtelServices;
2224

@@ -26,22 +28,23 @@ public OpenTelemetryControllerTests()
2628
}
2729

2830
[Theory]
29-
[InlineData("true", true)]
30-
[InlineData("false", false)]
3131
[InlineData("True", true)]
3232
[InlineData("False", false)]
33+
[InlineData("true", true)]
34+
[InlineData("false", false)]
3335
[InlineData(null, false)]
3436
internal void OpenTelemetryEnvironmentVariableCheckWorks(string? environmentVariableValue, bool desiredResult)
3537
{
3638
try
3739
{
38-
Environment.SetEnvironmentVariable("OTEL_FUNCTIONS_WORKER_ENABLED", environmentVariableValue);
40+
Environment.SetEnvironmentVariable(OTelEnabledEnvironmentVariableName, environmentVariableValue);
41+
OpenTelemetryController.ResetOpenTelemetryModuleStatus();
3942

4043
Assert.Equal(desiredResult, OpenTelemetryController.IsOpenTelemetryEnvironmentEnabled());
4144
}
4245
finally
4346
{
44-
Environment.SetEnvironmentVariable("OTEL_FUNCTIONS_WORKER_ENABLED", null);
47+
Environment.SetEnvironmentVariable(OTelEnabledEnvironmentVariableName, null);
4548
OpenTelemetryController.ResetOpenTelemetryModuleStatus();
4649
}
4750
}

0 commit comments

Comments
 (0)