refactor(worker): remove MessageParser (replaced by StreamAnalyzer)
This commit is contained in:
41
tests/ClaudeDo.Worker.Tests/CLAUDE.md
Normal file
41
tests/ClaudeDo.Worker.Tests/CLAUDE.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# ClaudeDo.Worker.Tests
|
||||
|
||||
xUnit integration tests for the Worker and Data layers.
|
||||
|
||||
## Framework
|
||||
|
||||
- xUnit 2.5.3 with `xunit.runner.visualstudio`
|
||||
- No mocking library — custom sealed fakes (FakeClaudeProcess, FakeHubContext, FakeHubClients, FakeClientProxy)
|
||||
- Real SQLite databases per test via `DbFixture`
|
||||
- Real git repos for worktree tests via `GitRepoFixture`
|
||||
- coverlet for coverage collection
|
||||
|
||||
## Test Infrastructure
|
||||
|
||||
- **DbFixture** — creates unique temp SQLite DB, applies schema, cleans up DB + WAL/SHM files on dispose
|
||||
- **GitRepoFixture** — creates temp git repo with initial commit, configures user/email, handles Windows read-only .git cleanup. Tests skip if git is unavailable.
|
||||
|
||||
## Test Areas
|
||||
|
||||
| Area | File | What it covers |
|
||||
|------|------|----------------|
|
||||
| Repositories | `ListRepositoryTests` | CRUD, tag junctions |
|
||||
| | `TaskRepositoryTests` | CRUD, status transitions, agent tag filtering, effective tags, stale flip |
|
||||
| Runner | `WorktreeManagerTests` | Worktree creation, commit detection, error on non-git dir |
|
||||
| | `CommitMessageBuilderTests` | Slug generation, title/description truncation |
|
||||
| | `MessageParserTests` | NDJSON parsing, malformed input |
|
||||
| Services | `QueueServiceTests` | FIFO ordering, override slot contention, cancellation, active tracking |
|
||||
| | `StaleTaskRecoveryTests` | Flips orphaned running tasks to failed |
|
||||
|
||||
## Conventions
|
||||
|
||||
- Test classes implement `IDisposable` and create fixtures in constructor
|
||||
- Helper factory methods for entities: `MakeTask()`, `CreateListAsync()`, `SeedListWithAgentTag()`
|
||||
- Concurrency tests use `TaskCompletionSource` as gates for deterministic ordering
|
||||
- Git-dependent tests are conditionally skipped via `Skip = ...` when git is not available
|
||||
|
||||
## Running
|
||||
|
||||
```bash
|
||||
dotnet test tests/ClaudeDo.Worker.Tests
|
||||
```
|
||||
@@ -1,53 +0,0 @@
|
||||
using ClaudeDo.Worker.Runner;
|
||||
|
||||
namespace ClaudeDo.Worker.Tests.Runner;
|
||||
|
||||
public sealed class MessageParserTests
|
||||
{
|
||||
[Fact]
|
||||
public void WellFormed_Result_Line_Extracts_Result()
|
||||
{
|
||||
var line = """{"type":"result","result":"Hello **world**"}""";
|
||||
Assert.True(MessageParser.TryExtractResult(line, out var result));
|
||||
Assert.Equal("Hello **world**", result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Non_Result_Type_Returns_False()
|
||||
{
|
||||
var line = """{"type":"assistant","message":"hi"}""";
|
||||
Assert.False(MessageParser.TryExtractResult(line, out var result));
|
||||
Assert.Null(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Missing_Type_Property_Returns_False()
|
||||
{
|
||||
var line = """{"result":"data"}""";
|
||||
Assert.False(MessageParser.TryExtractResult(line, out var result));
|
||||
Assert.Null(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Malformed_Json_Returns_False_No_Throw()
|
||||
{
|
||||
var line = "this is not json {{{";
|
||||
Assert.False(MessageParser.TryExtractResult(line, out var result));
|
||||
Assert.Null(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Empty_Line_Returns_False()
|
||||
{
|
||||
Assert.False(MessageParser.TryExtractResult("", out _));
|
||||
Assert.False(MessageParser.TryExtractResult(" ", out _));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Null_Result_Value_Returns_True_With_Null()
|
||||
{
|
||||
var line = """{"type":"result","result":null}""";
|
||||
Assert.True(MessageParser.TryExtractResult(line, out var result));
|
||||
Assert.Null(result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user