fix tests

This commit is contained in:
Francesco Renzi
2026-03-23 10:23:45 +00:00
committed by GitHub
parent 161a64b7e0
commit d18ff19d96
2 changed files with 14 additions and 42 deletions

View File

@@ -228,7 +228,7 @@ namespace GitHub.Runner.Worker.Dap
/// <summary>
/// Infers a simple DAP type hint from the string representation of a result.
/// </summary>
private static string InferResultType(string value)
internal static string InferResultType(string value)
{
value = value?.ToLower();
if (value == null || value == "null")
@@ -290,14 +290,6 @@ namespace GitHub.Runner.Worker.Dap
EvaluateName = $"${{{{ {childPath} }}}}"
};
if (value == null)
{
variable.Value = "null";
variable.Type = "null";
variable.VariablesReference = 0;
return variable;
}
// Secrets scope: redact ALL values regardless of underlying type.
// Keys are visible but values are always replaced with the
// redaction marker, and nested containers are not drillable.
@@ -309,6 +301,14 @@ namespace GitHub.Runner.Worker.Dap
return variable;
}
if (value == null)
{
variable.Value = "null";
variable.Type = "null";
variable.VariablesReference = 0;
return variable;
}
switch (value)
{
case StringContextData str:

View File

@@ -126,34 +126,6 @@ namespace GitHub.Runner.Common.Tests.Worker
}
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Worker")]
public void GetScopes_StableVariablesReferenceIds()
{
using (CreateTestContext())
{
// Populate all 10 scopes and verify their reference IDs
// are stable and based on array position
var exprValues = new DictionaryContextData();
foreach (var name in DapVariableProvider.ScopeNames)
{
exprValues[name] = new DictionaryContextData();
}
var ctx = CreateMockContext(exprValues);
var scopes = _provider.GetScopes(ctx.Object);
Assert.Equal(DapVariableProvider.ScopeNames.Length, scopes.Count);
for (int i = 0; i < scopes.Count; i++)
{
Assert.Equal(DapVariableProvider.ScopeNames[i], scopes[i].Name);
// Reference IDs are 1-based: index 0 -> ref 1, index 1 -> ref 2, etc.
Assert.Equal(i + 1, scopes[i].VariablesReference);
}
}
}
#endregion
#region GetVariables basic types
@@ -382,7 +354,7 @@ namespace GitHub.Runner.Common.Tests.Worker
Assert.Equal(2, variables.Count);
foreach (var v in variables)
{
Assert.Equal(DapVariableProvider.RedactedValue, v.Value);
Assert.Equal("***", v.Value);
Assert.Equal("string", v.Type);
}
@@ -670,7 +642,7 @@ namespace GitHub.Runner.Common.Tests.Worker
Assert.Single(variables);
Assert.Equal("NUMERIC_SECRET", variables[0].Name);
Assert.Equal(DapVariableProvider.RedactedValue, variables[0].Value);
Assert.Equal("***", variables[0].Value);
Assert.Equal("string", variables[0].Type);
Assert.Equal(0, variables[0].VariablesReference);
}
@@ -694,7 +666,7 @@ namespace GitHub.Runner.Common.Tests.Worker
Assert.Single(variables);
Assert.Equal("BOOL_SECRET", variables[0].Name);
Assert.Equal(DapVariableProvider.RedactedValue, variables[0].Value);
Assert.Equal("***", variables[0].Value);
Assert.Equal("string", variables[0].Type);
Assert.Equal(0, variables[0].VariablesReference);
}
@@ -722,7 +694,7 @@ namespace GitHub.Runner.Common.Tests.Worker
Assert.Single(variables);
Assert.Equal("NESTED_SECRET", variables[0].Name);
Assert.Equal(DapVariableProvider.RedactedValue, variables[0].Value);
Assert.Equal("***", variables[0].Value);
Assert.Equal("string", variables[0].Type);
// Nested container should NOT be drillable under secrets
Assert.Equal(0, variables[0].VariablesReference);
@@ -746,7 +718,7 @@ namespace GitHub.Runner.Common.Tests.Worker
Assert.Single(variables);
Assert.Equal("NULL_SECRET", variables[0].Name);
Assert.Equal(DapVariableProvider.RedactedValue, variables[0].Value);
Assert.Equal("***", variables[0].Value);
Assert.Equal(0, variables[0].VariablesReference);
}
}