53 lines
2.4 KiB
C#
53 lines
2.4 KiB
C#
using Sdt.Core;
|
|
using Xunit;
|
|
|
|
namespace DevTool.Tests;
|
|
|
|
public sealed class RunHistoryTests
|
|
{
|
|
[Fact]
|
|
public void ListRunHistory_ParsesWorkflowTarget()
|
|
{
|
|
var root = Path.Combine(Path.GetTempPath(), "sdt-history-" + Guid.NewGuid().ToString("N"));
|
|
var dir = Path.Combine(root, ".sdt", "events");
|
|
Directory.CreateDirectory(dir);
|
|
var file = Path.Combine(dir, "workflow-test.jsonl");
|
|
File.WriteAllLines(file,
|
|
[
|
|
"""{"category":"workflow","event_type":"WorkflowStarted","message":"Workflow 'build' started.","workflowId":"build","run_event_version":"1.0","run_id":"rid-1","project_root":"C:/repo","timestamp_utc":"2026-03-01T10:00:00Z"}""",
|
|
"""{"category":"workflow","event_type":"WorkflowCompleted","message":"Workflow completed successfully.","workflowId":"build","success":true,"exitCode":0,"run_event_version":"1.0","run_id":"rid-1","project_root":"C:/repo","timestamp_utc":"2026-03-01T10:00:01Z"}"""
|
|
]);
|
|
|
|
var reader = new RunEventLogReader();
|
|
var history = reader.ListRunHistory(root);
|
|
|
|
Assert.Single(history);
|
|
Assert.Equal("workflow", history[0].Category);
|
|
Assert.Equal("build", history[0].TargetId);
|
|
Assert.True(history[0].Success);
|
|
}
|
|
|
|
[Fact]
|
|
public void ListRunHistory_ParsesDebugProfileFromMessage()
|
|
{
|
|
var root = Path.Combine(Path.GetTempPath(), "sdt-history-" + Guid.NewGuid().ToString("N"));
|
|
var dir = Path.Combine(root, ".sdt", "events");
|
|
Directory.CreateDirectory(dir);
|
|
var file = Path.Combine(dir, "debug-test.jsonl");
|
|
File.WriteAllLines(file,
|
|
[
|
|
"""{"category":"debug","event_type":"DebugStarted","message":"Debug profile 'dotnet-run' started.","run_event_version":"1.0","run_id":"rid-2","project_root":"C:/repo","timestamp_utc":"2026-03-01T10:00:00Z"}""",
|
|
"""{"category":"debug","event_type":"DebugCompleted","message":"Debug run completed.","success":true,"exitCode":0,"run_event_version":"1.0","run_id":"rid-2","project_root":"C:/repo","timestamp_utc":"2026-03-01T10:00:01Z"}"""
|
|
]);
|
|
|
|
var reader = new RunEventLogReader();
|
|
var history = reader.ListRunHistory(root);
|
|
|
|
Assert.Single(history);
|
|
Assert.Equal("debug", history[0].Category);
|
|
Assert.Equal("dotnet-run", history[0].TargetId);
|
|
Assert.True(history[0].Success);
|
|
}
|
|
}
|
|
|