Fase 11 — Decisioni solo matematiche (#186)
ci / test (postgres) (push) Successful in 7m36s
ci / test (sqlite) (push) Successful in 6m41s
ci / image (push) Successful in 1m49s

News, the economic calendar and earnings dates no longer change any decision (ADR 0023, choices in ADR 0027). The outside rules are measured in the shadow; a switch in the settings turns them back on.

refs #116, refs #117

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #186.
This commit is contained in:
Alby96andClaude Opus 5.5 authored and Alby96 committed 2026-12-04 09:14:11 +01:00
1 parent ed22d1c8b5
commit 93cdf7850d
47 files changed
+1743 -169

No files matched your search

+17
View File
@@ -17,9 +17,26 @@ public sealed class DatabaseTests
{
var test = await TestDb.CreateAsync().ConfigureAwait(false);
await Migrations.MigrateAsync(test.Db, _clock, null, CancellationToken.None).ConfigureAwait(false);
// The rules of the news act in the tests of Phase 7 (ADR 0027 point 3): set here, without a change in the log. A
// test of «misurate» asks for it.
await test.Db.WriteAsync(s => s.ExecuteAsync("INSERT INTO config (id, key, value, created_at, updated_at) VALUES (@id, @k, @v, @t, @t)", CancellationToken.None,
("id", Ids.NewId(_clock)), ("k", News.ExternalRules.Setting.Key), ("v", new DbJson(System.Text.Json.JsonSerializer.Serialize(News.ExternalRules.Active))), ("t", _clock.UtcNow)))
.ConfigureAwait(false);
return test;
}
/// <summary>
/// Puts the rules of the news back to the default of ADR 0023, «misurate», in a database of <see cref="MigratedAsync"/>;
/// <paramref name="since"/> is when the switch was written, as on a new installation.
/// </summary>
internal static Task MeasuredAsync(Database db, DateTimeOffset? since = null) =>
db.WriteAsync(s => since is { } at
? s.ExecuteAsync("UPDATE config SET value = @v, created_at = @t, updated_at = @t WHERE key = @k", CancellationToken.None,
("k", News.ExternalRules.Setting.Key), ("v", new DbJson(System.Text.Json.JsonSerializer.Serialize(News.ExternalRules.Measured))), ("t", at))
: s.ExecuteAsync("UPDATE config SET value = @v WHERE key = @k", CancellationToken.None,
("k", News.ExternalRules.Setting.Key), ("v", new DbJson(System.Text.Json.JsonSerializer.Serialize(News.ExternalRules.Measured)))));
[TestMethod]
[TestCategory(Category.Integration)]
public async Task MigrationsCreateTheSchemaAndRunOnce()