using System.Collections.Concurrent;
using ClaudeDo.Worker.Skills;

namespace ClaudeDo.Worker.Tests.Infrastructure;

public sealed class FakeSessionSkillSeeder : ISessionSkillSeeder
{
    public int CallCount;
    public readonly record struct Call(string WorkingDir, IReadOnlyList<string> SkillNames, bool IsWorktree);
    public readonly ConcurrentQueue<Call> Calls = new();

    // Lets a test simulate a seeding failure (e.g. a broken skill install) to verify callers
    // don't leave a task stuck Running when SeedAsync throws.
    public Exception? ThrowOnSeed;

    public Task SeedAsync(string workingDir, IReadOnlyList<string> skillNames, bool isWorktree, CancellationToken ct)
    {
        Interlocked.Increment(ref CallCount);
        Calls.Enqueue(new Call(workingDir, skillNames, isWorktree));
        if (ThrowOnSeed is not null) throw ThrowOnSeed;
        return Task.CompletedTask;
    }
}
