Skip to content

Commit 3d61e1e

Browse files
CopilotCopilot
andcommitted
fix: add test collection and disable parallelization to prevent intermittent failures
- Add [Collection("ConfigFile")] to SecurityHardeningTests to prevent interference with config file tests - Create xunit.runner.json to disable test parallelization in Graphify.Tests - Refactor BuildSerializableConfig to extract provider key for clarity These changes address intermittent test failures in Release mode where the JSON serialization of provider config sections was being skipped or omitted. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent fe43d54 commit 3d61e1e

5 files changed

Lines changed: 56 additions & 13 deletions

File tree

debug-test.csx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System.Text.Json;
2+
using Graphify.Cli.Configuration;
3+
4+
var config = new GraphifyConfig
5+
{
6+
Provider = "ollama",
7+
Ollama = new OllamaConfig
8+
{
9+
Endpoint = "http://localhost:11434",
10+
ModelId = "llama3.2"
11+
}
12+
};
13+
14+
ConfigPersistence.Save(config);
15+
16+
var configPath = ConfigPersistence.GetLocalConfigPath();
17+
var json = File.ReadAllText(configPath);
18+
Console.WriteLine("=== SAVED JSON ===");
19+
Console.WriteLine(json);
20+
Console.WriteLine("=== END JSON ===");
21+
22+
using var doc = JsonDocument.Parse(json);
23+
if (doc.RootElement.TryGetProperty("Graphify", out var graphify))
24+
{
25+
Console.WriteLine($"Graphify section found: {graphify}");
26+
Console.WriteLine($"Has Ollama: {graphify.TryGetProperty("Ollama", out _)}");
27+
if (graphify.TryGetProperty("Ollama", out var ollama))
28+
{
29+
Console.WriteLine($"Ollama: {ollama}");
30+
}
31+
}

src/Graphify.Cli/Configuration/ConfigPersistence.cs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,32 +135,30 @@ private static bool StoreApiKeyInUserSecrets(string apiKey)
135135
if (config.ExportFormats != null)
136136
result["ExportFormats"] = config.ExportFormats;
137137

138-
switch (config.Provider?.ToLowerInvariant())
138+
var providerKey = config.Provider?.ToLowerInvariant();
139+
switch (providerKey)
139140
{
140141
case "azureopenai":
141142
// API key is stored in user-secrets, NOT in the JSON file
142-
var azureConfig = new Dictionary<string, string?>
143+
result["AzureOpenAI"] = new
143144
{
144-
["Endpoint"] = config.AzureOpenAI.Endpoint,
145-
["DeploymentName"] = config.AzureOpenAI.DeploymentName,
146-
["ModelId"] = config.AzureOpenAI.ModelId
145+
config.AzureOpenAI.Endpoint,
146+
config.AzureOpenAI.DeploymentName,
147+
config.AzureOpenAI.ModelId
147148
};
148-
result["AzureOpenAI"] = azureConfig;
149149
break;
150150
case "ollama":
151-
var ollamaConfig = new Dictionary<string, string>
151+
result["Ollama"] = new
152152
{
153-
["Endpoint"] = config.Ollama.Endpoint,
154-
["ModelId"] = config.Ollama.ModelId
153+
config.Ollama.Endpoint,
154+
config.Ollama.ModelId
155155
};
156-
result["Ollama"] = ollamaConfig;
157156
break;
158157
case "copilotsdk":
159-
var copilotConfig = new Dictionary<string, string>
158+
result["CopilotSdk"] = new
160159
{
161-
["ModelId"] = config.CopilotSdk.ModelId
160+
config.CopilotSdk.ModelId
162161
};
163-
result["CopilotSdk"] = copilotConfig;
164162
break;
165163
}
166164

src/tests/Graphify.Tests/Security/SecurityHardeningTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace Graphify.Tests.Security;
1010
/// error sanitization, config loading, cache permissions.
1111
/// Covers FINDING-001, FINDING-003, FINDING-009, FINDING-010, FINDING-011.
1212
/// </summary>
13+
[Collection("ConfigFile")]
1314
[Trait("Category", "Security")]
1415
public sealed class SecurityHardeningTests
1516
{
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
3+
"parallelizeAssembly": false,
4+
"parallelizeTestCollections": false
5+
}

test_output.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Test run for C:\src\graphify-dotnet\src\tests\Graphify.Integration.Tests\bin\Release\net10.0\Graphify.Integration.Tests.dll (.NETCoreApp,Version=v10.0)
2+
Test run for C:\src\graphify-dotnet\src\tests\Graphify.Tests\bin\Release\net10.0\Graphify.Tests.dll (.NETCoreApp,Version=v10.0)
3+
A total of 1 test files matched the specified pattern.
4+
A total of 1 test files matched the specified pattern.
5+
6+
Passed! - Failed: 0, Passed: 41, Skipped: 0, Total: 41, Duration: 2 s - Graphify.Integration.Tests.dll (net10.0)
7+
8+
Passed! - Failed: 0, Passed: 573, Skipped: 0, Total: 573, Duration: 30 s - Graphify.Tests.dll (net10.0)

0 commit comments

Comments
 (0)