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>
This commit is contained in:
ajandClaude Sonnet 5.5 committed 2026-12-03 15:17:02 -05:00
1 parent ad991edb9f
commit 1772eb04e0
3 files changed
+40 -1

No files matched your search

@@ -0,0 +1,34 @@
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);
}
}
@@ -31,4 +31,9 @@
<ProjectReference Include="..\OpenNest.Mcp\OpenNest.Mcp.csproj" Aliases="mcp" />
</ItemGroup>
<ItemGroup>
<!-- LegacyFixtureTests reads the container smoke's expected legacy metadata. -->
<None Include="..\scripts\Server.Tests\legacy_fixture.py" Link="legacy_fixture.py" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</Project>
+1 -1
View File
@@ -36,7 +36,7 @@ def create(directory):
'madeBy', 'fileSize', 'savedAt'), fields))
# Columns added by later migrations read back as their defaults.
metadata.update(status='toBeCut', revision=1, deleted=False, restoredFromRevision=None,
materialGrade='', units='inches', thicknessName='')
materialGrade='', units='inches', thicknessName='', jobNumber='')
archive = {'sha256': hashlib.sha256(data).hexdigest(), 'bytes': len(data)}
expected.append({'current': metadata, 'archive': archive,
'revisions': [{'metadata': metadata, 'archive': archive}]})