Skip to content

Commit 3f17bb0

Browse files
committed
Fix telemetry CLI test path assertions on macOS
1 parent 7781fd9 commit 3f17bb0

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

tests/KeelMatrix.QueryWatch.Cli.IntegrationTests/TelemetryCommandTests.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void Telemetry_Status_Shows_Enabled_When_No_Overrides_Exist() {
4949
_ = code.Should().Be(0, stdout + Environment.NewLine + stderr);
5050
_ = stdout.Should().Contain("Telemetry: enabled");
5151
_ = stdout.Should().Contain("Source: none");
52-
_ = stdout.Should().Contain($"Repo: {repo.Root}");
52+
_ = NormalizeForAssertion(stdout).Should().Contain($"Repo: {NormalizeForAssertion(repo.Root)}");
5353
_ = stdout.Should().Contain("Repo-local config: missing");
5454
}
5555

@@ -171,12 +171,12 @@ public void Telemetry_Status_Json_Uses_Status_Model() {
171171
JsonElement effectiveStatus = doc.RootElement.GetProperty("effectiveStatus");
172172
_ = effectiveStatus.GetProperty("isEnabled").GetBoolean().Should().BeFalse();
173173
_ = effectiveStatus.GetProperty("winningSourceKind").GetString().Should().Be("dotEnvLocal");
174-
_ = effectiveStatus.GetProperty("winningPath").GetString().Should().Be(Path.Combine(repo.Root, ".env.local"));
174+
_ = NormalizeForAssertion(effectiveStatus.GetProperty("winningPath").GetString()).Should().Be(NormalizeForAssertion(Path.Combine(repo.Root, ".env.local")));
175175
_ = effectiveStatus.GetProperty("winningVariableName").GetString().Should().Be("KEELMATRIX_NO_TELEMETRY");
176176
_ = effectiveStatus.GetProperty("scope").GetString().Should().Be("repoLocal");
177-
_ = effectiveStatus.GetProperty("repoRoot").GetString().Should().Be(repo.Root);
177+
_ = NormalizeForAssertion(effectiveStatus.GetProperty("repoRoot").GetString()).Should().Be(NormalizeForAssertion(repo.Root));
178178
_ = doc.RootElement.GetProperty("repoLocalConfigState").GetString().Should().Be("missing");
179-
_ = doc.RootElement.GetProperty("repoLocalConfigPath").GetString().Should().Be(Path.Combine(repo.Root, "keelmatrix.telemetry.json"));
179+
_ = NormalizeForAssertion(doc.RootElement.GetProperty("repoLocalConfigPath").GetString()).Should().Be(NormalizeForAssertion(Path.Combine(repo.Root, "keelmatrix.telemetry.json")));
180180
}
181181

182182
[Fact]
@@ -517,6 +517,18 @@ public void Dispose() {
517517
}
518518
}
519519

520+
private static string NormalizeForAssertion(string? value) {
521+
value.Should().NotBeNull();
522+
523+
if (!OperatingSystem.IsMacOS())
524+
return value!;
525+
526+
const string macOsPrivatePrefix = "/private/";
527+
return value!.StartsWith(macOsPrivatePrefix, StringComparison.Ordinal)
528+
? value[(macOsPrivatePrefix.Length - 1)..]
529+
: value;
530+
}
531+
520532
private sealed class EnvironmentVariableSnapshot : IDisposable {
521533
private readonly (string Name, string? Value)[] snapshot;
522534

0 commit comments

Comments
 (0)