Rehydrate default loop on empty snapshot

This commit is contained in:
Jacob Dubin
2026-05-19 20:06:03 -05:00
parent 30493d554b
commit b172a00454
11 changed files with 45355 additions and 3 deletions

View File

@@ -128,6 +128,33 @@ public sealed class PersistenceStoreTests
}
}
[Fact]
public void CloudStateStore_RehydratesDefaultLoopWhenSnapshotLoopsAreMissing()
{
var persistencePath = Path.Combine(Path.GetTempPath(), $"openjibo-cloud-empty-loops-{Guid.NewGuid():N}.json");
try
{
File.WriteAllText(persistencePath, """
{
"SchemaVersion": "1",
"Revision": 7,
"Loops": []
}
""");
var store = new InMemoryCloudStateStore(persistencePath);
Assert.NotEmpty(store.GetLoops());
Assert.Equal("openjibo-default-loop", store.GetLoops()[0].LoopId);
Assert.NotEmpty(store.GetPeople());
}
finally
{
if (File.Exists(persistencePath)) File.Delete(persistencePath);
}
}
private sealed class RecordingSnapshotStore : ISnapshotStore
{
public List<object> Saves { get; } = [];
@@ -142,4 +169,4 @@ public sealed class PersistenceStoreTests
Saves.Add(snapshot);
}
}
}
}