Merge claudedo/1bbc77a12e0844b2a037bf44cfb47eae
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
using ClaudeDo.Data.Models;
|
||||
using ClaudeDo.Data.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace ClaudeDo.Data.Tests;
|
||||
|
||||
public sealed class PrimeScheduleRepositoryTests : IDisposable
|
||||
{
|
||||
private readonly string _dbPath;
|
||||
private readonly ClaudeDoDbContext _ctx;
|
||||
private readonly PrimeScheduleRepository _repo;
|
||||
|
||||
public PrimeScheduleRepositoryTests()
|
||||
{
|
||||
_dbPath = Path.Combine(Path.GetTempPath(), $"claudedo_prime_{Guid.NewGuid():N}.db");
|
||||
var options = new DbContextOptionsBuilder<ClaudeDoDbContext>()
|
||||
.UseSqlite($"Data Source={_dbPath}")
|
||||
.Options;
|
||||
_ctx = new ClaudeDoDbContext(options);
|
||||
_ctx.Database.EnsureCreated();
|
||||
_repo = new PrimeScheduleRepository(_ctx);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_ctx.Dispose();
|
||||
foreach (var suffix in new[] { "", "-wal", "-shm" })
|
||||
try { File.Delete(_dbPath + suffix); } catch { }
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task UpsertAsync_then_GetAsync_roundtrips_the_prompt_override()
|
||||
{
|
||||
var entity = new PrimeScheduleEntity { PromptOverride = "Also prioritize anything tagged #urgent." };
|
||||
|
||||
await _repo.UpsertAsync(entity);
|
||||
var found = await _repo.GetAsync(entity.Id);
|
||||
|
||||
Assert.NotNull(found);
|
||||
Assert.Equal("Also prioritize anything tagged #urgent.", found!.PromptOverride);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task UpsertAsync_with_null_override_persists_as_null()
|
||||
{
|
||||
var entity = new PrimeScheduleEntity { PromptOverride = null };
|
||||
|
||||
await _repo.UpsertAsync(entity);
|
||||
var found = await _repo.GetAsync(entity.Id);
|
||||
|
||||
Assert.NotNull(found);
|
||||
Assert.Null(found!.PromptOverride);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task UpsertAsync_updates_the_override_on_an_existing_row()
|
||||
{
|
||||
var entity = new PrimeScheduleEntity { PromptOverride = "old override" };
|
||||
await _repo.UpsertAsync(entity);
|
||||
|
||||
entity.PromptOverride = "new override";
|
||||
await _repo.UpsertAsync(entity);
|
||||
|
||||
var found = await _repo.GetAsync(entity.Id);
|
||||
Assert.Equal("new override", found!.PromptOverride);
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,43 @@ public class DailyPrepPromptTests
|
||||
Assert.Contains("preparing my workday", prompt);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Build_prompt_without_override_matches_the_plain_render()
|
||||
{
|
||||
var today = new DateOnly(2026, 6, 3);
|
||||
var expected = ClaudeDo.Data.PromptFiles.Render(
|
||||
ClaudeDo.Data.PromptKind.DailyPrep,
|
||||
new Dictionary<string, string> { ["date"] = "2026-06-03", ["maxTasks"] = "5" });
|
||||
|
||||
var prompt = DailyPrepPrompt.BuildPrompt(maxTasks: 5, today: today);
|
||||
|
||||
Assert.Equal(expected, prompt);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Build_prompt_appends_override_as_an_additional_paragraph()
|
||||
{
|
||||
var today = new DateOnly(2026, 6, 3);
|
||||
var baseline = DailyPrepPrompt.BuildPrompt(maxTasks: 5, today: today);
|
||||
|
||||
var prompt = DailyPrepPrompt.BuildPrompt(maxTasks: 5, today: today,
|
||||
promptOverride: "Also prioritize anything tagged #urgent.");
|
||||
|
||||
Assert.StartsWith(baseline, prompt);
|
||||
Assert.Contains("Also prioritize anything tagged #urgent.", prompt);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Build_prompt_treats_whitespace_only_override_as_absent()
|
||||
{
|
||||
var today = new DateOnly(2026, 6, 3);
|
||||
var baseline = DailyPrepPrompt.BuildPrompt(maxTasks: 5, today: today);
|
||||
|
||||
var prompt = DailyPrepPrompt.BuildPrompt(maxTasks: 5, today: today, promptOverride: " ");
|
||||
|
||||
Assert.Equal(baseline, prompt);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Build_args_allows_only_the_two_tools()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user