Write the manuals and fix what following them found
The manual, the runbook and the go-live list are written and checked claim by claim against the code, and the installation is done from zero by following them on both engines. That found real defects, now fixed: - with SQLite a missing database file left no way to restore a backup: the choices appear, and the file is created only by the user's choice; - an account whose difference vanished after the 15 minutes stayed prudent with no button, a missing stop could be left out for good, and a choice made while the broker was silent used old numbers; - after "Ferma tutto" the positions could not be closed without restarting; - a refused key looked like a silent broker: it has its own notice now; - the split of the capital between the strategies of a broker (SPEC 13.5) could not be changed from the interface. refs #72 #68 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2257c3e16c
commit
24e20584d4
28 files changed
+1147
-57
No files matched your search
@@ -58,6 +58,71 @@ public sealed class RestoreServerTests
|
||||
}, null);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task AMissingSqliteFileOffersTheRestoreAndNeverCreatesADatabaseByItself()
|
||||
{
|
||||
var data = TempFolder.Create("missing-file");
|
||||
var file = new DataDirectory(data).SqliteFile;
|
||||
await using (var first = await ServerHarness.StartAsync("docker", ServerHarness.DockerSqlite(), dataDir: data))
|
||||
{
|
||||
await first.SignInFirstTimeAsync();
|
||||
using var saved = await first.PostFormAsync("/impostazioni", "/azioni/salvataggio");
|
||||
}
|
||||
|
||||
Microsoft.Data.Sqlite.SqliteConnection.ClearAllPools();
|
||||
var away = data + "-altrove.sqlite3";
|
||||
File.Copy(file, away, overwrite: true);
|
||||
foreach (var f in Directory.EnumerateFiles(Path.GetDirectoryName(file)!))
|
||||
{
|
||||
File.Delete(f);
|
||||
}
|
||||
|
||||
// The file comes back while the page waits: it is used, with no choice to make.
|
||||
await using (var server = await ServerHarness.StartAsync("docker", ServerHarness.DockerSqlite(), dataDir: data, waitReady: false))
|
||||
{
|
||||
await server.WaitForAsync(HostMode.IdentityProblem);
|
||||
StringAssert.Contains(await server.TextAsync("/"), "Il file del database non c'è");
|
||||
using var health = await server.GetAsync("/health");
|
||||
Assert.AreEqual(HttpStatusCode.ServiceUnavailable, health.StatusCode);
|
||||
using (var wrong = await server.PostFormAsync("/", "/azioni/servizio/da-capo", ("password", "wrong-password-123")))
|
||||
{
|
||||
StringAssert.Contains(ServerHarness.Location(wrong), "errore=password");
|
||||
}
|
||||
|
||||
using (var unknown = await server.PostFormAsync("/", "/azioni/servizio/ripristina", ("password", ServerHarness.AdminPassword), ("salvataggio", "inesistente")))
|
||||
{
|
||||
StringAssert.Contains(ServerHarness.Location(unknown), "errore=scelta");
|
||||
}
|
||||
|
||||
Assert.IsFalse(File.Exists(file), "Trap 20: no database by itself.");
|
||||
File.Copy(away, file);
|
||||
await server.WaitForAsync(HostMode.Ready);
|
||||
}
|
||||
|
||||
Microsoft.Data.Sqlite.SqliteConnection.ClearAllPools();
|
||||
foreach (var f in Directory.EnumerateFiles(Path.GetDirectoryName(file)!))
|
||||
{
|
||||
File.Delete(f);
|
||||
}
|
||||
|
||||
await using (var server = await ServerHarness.StartAsync("docker", ServerHarness.DockerSqlite(), dataDir: data, waitReady: false))
|
||||
{
|
||||
await server.WaitForAsync(HostMode.IdentityProblem);
|
||||
var backup = new Backups(new DataDirectory(data), SystemClock.Instance).List().Single(b => b.Reason == "a-mano");
|
||||
using (var restore = await server.PostFormAsync("/", "/azioni/servizio/ripristina", ("password", ServerHarness.AdminPassword), ("salvataggio", backup.Name)))
|
||||
{
|
||||
Assert.AreEqual("/", ServerHarness.Location(restore));
|
||||
}
|
||||
|
||||
await server.WaitForAsync(HostMode.Ready);
|
||||
Assert.IsTrue((await Installation.ReadRowAsync(server.Host.Services!.Db))!.ProtectedRestart);
|
||||
Assert.AreEqual("stopped", (await server.Host.Services.Settings.GetAsync(SettingsStore.BotState.Key)).Value);
|
||||
}
|
||||
|
||||
File.Delete(away);
|
||||
TempFolder.Delete(data);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task AfterARestoreTheOldDatabaseIsRefusedAndTheNewOneWaitsForTheUser()
|
||||
{
|
||||
@@ -95,6 +160,13 @@ public sealed class RestoreServerTests
|
||||
Assert.AreEqual("stopped", (await server.Host.Services!.Settings.GetAsync(SettingsStore.BotState.Key)).Value);
|
||||
}
|
||||
|
||||
// Nor is anything sold from a ledger that has not read the accounts yet.
|
||||
Assert.IsFalse((await server.TextAsync("/rischio")).Contains("Chiudi tutte le posizioni", StringComparison.Ordinal));
|
||||
using (var close = await server.PostFormAsync("/rischio", "/azioni/bot/chiudi"))
|
||||
{
|
||||
StringAssert.Contains(ServerHarness.Location(close), "errore");
|
||||
}
|
||||
|
||||
Assert.HasCount(1, await server.Host.Services!.Db.ReadAsync(s => s.QueryAsync("SELECT message FROM journal WHERE code = 'protected_restart'", r => r.Text("message"))));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user