Rehydrate default loop on empty snapshot
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user