46 lines
1.5 KiB
C#
46 lines
1.5 KiB
C#
using StellaOps.PacksRegistry.Core.Models;
|
|
using StellaOps.PacksRegistry.Infrastructure.FileSystem;
|
|
|
|
namespace StellaOps.PacksRegistry.Tests;
|
|
|
|
public sealed class FilePackRepositoryTests
|
|
{
|
|
[Fact]
|
|
public async Task Upsert_and_List_round_trip()
|
|
{
|
|
var tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("N"));
|
|
Directory.CreateDirectory(tempPath);
|
|
try
|
|
{
|
|
var ct = TestContext.Current.CancellationToken;
|
|
var repo = new FilePackRepository(tempPath);
|
|
|
|
var record = new PackRecord(
|
|
PackId: "demo@1.0.0",
|
|
Name: "demo",
|
|
Version: "1.0.0",
|
|
TenantId: "t1",
|
|
Digest: "sha256:abc",
|
|
Signature: null,
|
|
ProvenanceUri: null,
|
|
ProvenanceDigest: null,
|
|
CreatedAtUtc: DateTimeOffset.Parse("2025-11-24T00:00:00Z"),
|
|
Metadata: new Dictionary<string, string> { ["lang"] = "csharp" });
|
|
|
|
await repo.UpsertAsync(record, new byte[] { 1, 2, 3 }, null, ct);
|
|
|
|
var listed = await repo.ListAsync("t1", ct);
|
|
Assert.Single(listed);
|
|
Assert.Equal(record.PackId, listed[0].PackId);
|
|
|
|
var fetched = await repo.GetAsync("demo@1.0.0", ct);
|
|
Assert.NotNull(fetched);
|
|
Assert.Equal(record.Digest, fetched!.Digest);
|
|
}
|
|
finally
|
|
{
|
|
Directory.Delete(tempPath, recursive: true);
|
|
}
|
|
}
|
|
}
|