Files
OpenNest/OpenNest.Server.Tests/LegacyFixtureTests.cs
T
ajandClaude Sonnet 5.5 1772eb04e0 fix(ci): expect a blank job number on migrated legacy nests
The container smoke compares migrated legacy records field for field, so
the Server image workflow failed once records gained jobNumber. Add a
unit test that checks the fixture lists every record field, which catches
the next new field without Docker.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-12-03 15:17:02 -05:00

35 lines
1.4 KiB
C#

using System.Text.Json;
using System.Text.RegularExpressions;
using OpenNest.Data;
namespace OpenNest.Server.Tests;
/// <summary>
/// The container smoke compares a migrated legacy database with the manifest that
/// scripts/Server.Tests/legacy_fixture.py expects, field for field. It needs Docker, so this
/// catches a new record field the fixture does not list before the workflow does.
/// </summary>
public sealed class LegacyFixtureTests
{
[Fact]
public void ExpectedLegacyMetadata_ListsEveryRecordField()
{
var script = File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "legacy_fixture.py"));
// The legacy columns, then the values later migrations and history add.
var legacy = Regex.Match(script, @"dict\(zip\(\((?<names>[^)]*)\)").Groups["names"].Value;
var added = Regex.Match(script, @"metadata\.update\((?<values>[^)]*)\)").Groups["values"].Value;
var expected = Regex.Matches(legacy, @"'(\w+)'")
.Concat(Regex.Matches(added, @"(\w+)="))
.Select(match => match.Groups[1].Value)
.Distinct()
.Order(StringComparer.Ordinal);
var actual = JsonSerializer.SerializeToElement(new NestRecord(), new JsonSerializerOptions(JsonSerializerDefaults.Web))
.EnumerateObject()
.Select(property => property.Name)
.Order(StringComparer.Ordinal);
Assert.Equal(actual, expected);
}
}