Skip to content

Commit

Permalink
Add missing telemetry test
Browse files Browse the repository at this point in the history
Add a test for the telemetry change made in #3090
  • Loading branch information
shyamnamboodiripad committed Oct 5, 2023
1 parent 599484e commit 69a3c0a
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions src/dotnet-interactive.Tests/CommandLine/StartupTelemetryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public async Task Invalid_command_is_does_not_send_any_telemetry()
}

[Fact]
public async Task stdio_command_sends_fronted_telemetry()
public async Task stdio_command_sends_frontend_telemetry()
{
await _parser.InvokeAsync("[synapse] stdio", _console);
_fakeTelemetrySender.TelemetryEvents.Should().Contain(
Expand All @@ -240,7 +240,24 @@ public async Task stdio_command_sends_fronted_telemetry()
}

[Fact]
public async Task githubCodeSpaces_is_a_valid_fronted_for_stdio()
public async Task stdio_command_sends_frontend_telemetry_when_frontend_is_VS()
{
await _parser.InvokeAsync(
"""
[vs9628] stdio --working-dir D:\Notebooks --kernel-host 9628-5c7e913f-8966-4afe-8d37-cc863292a352
""",
_console);

_fakeTelemetrySender.TelemetryEvents.Should().Contain(
x => x.EventName == "command" &&
x.Properties.Count == 3 &&
x.Properties["verb"] == "STDIO".ToSha256Hash() &&
x.Properties["frontend"] == "vs" &&
x.Properties["default-kernel"] == "CSHARP".ToSha256Hash());
}

[Fact]
public async Task githubCodeSpaces_is_a_valid_frontend_for_stdio()
{
Environment.SetEnvironmentVariable("CODESPACES", "true");
try
Expand Down Expand Up @@ -284,7 +301,7 @@ public async Task frontend_can_be_set_via_environment_variable()
}

[Fact]
public async Task vscode_is_a_valid_fronted_for_stdio()
public async Task vscode_is_a_valid_frontend_for_stdio()
{
await _parser.InvokeAsync("[vscode] stdio", _console);

Expand All @@ -297,7 +314,7 @@ public async Task vscode_is_a_valid_fronted_for_stdio()
}

[Fact]
public async Task stdio_command_sends_default_fronted_telemetry()
public async Task stdio_command_sends_default_frontend_telemetry()
{
var defaultFrontend = GetDefaultFrontendName();
await _parser.InvokeAsync("stdio", _console);
Expand All @@ -311,7 +328,7 @@ public async Task stdio_command_sends_default_fronted_telemetry()

private static string GetDefaultFrontendName()
{
var frontendName = Environment.GetEnvironmentVariable("DOTNET_INTERACTIVE_FRONTEND_NAME");
var frontendName = Environment.GetEnvironmentVariable("DOTNET_INTERACTIVE_FRONTEND_NAME");
frontendName = string.IsNullOrWhiteSpace(frontendName) ? "unknown" : frontendName;
return frontendName;
}
Expand Down

0 comments on commit 69a3c0a

Please sign in to comment.