Fix Lockfile Schematics

This commit is contained in:
2026-04-10 12:32:27 +02:00
parent 543945f099
commit 9300033e95
2 changed files with 130 additions and 2 deletions
+23
View File
@@ -108,6 +108,29 @@ func TestResolvedTableRegistryRegistersConsistentTables(t *testing.T) {
}
}
func TestSaveLockfilePreservesExistingOrderAndAppendsNewKeys(t *testing.T) {
root := t.TempDir()
lockPath := filepath.Join(root, "lock.json")
writeFile(t, lockPath, "{\n \"b\": 2,\n \"a\": 1\n}\n")
if err := saveLockfile(lockPath, map[string]int{
"b": 2,
"a": 1,
"c": 3,
}); err != nil {
t.Fatalf("saveLockfile failed: %v", err)
}
got, err := os.ReadFile(lockPath)
if err != nil {
t.Fatalf("read lockfile: %v", err)
}
want := "{\n \"b\": 2,\n \"a\": 1,\n \"c\": 3\n}\n"
if string(got) != want {
t.Fatalf("unexpected lockfile contents:\n%s", string(got))
}
}
func TestResolvedTableRegistryRejectsDuplicateKeys(t *testing.T) {
_, err := newResolvedTableRegistry([]nativeCollectedDataset{
{