summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-08-11 13:05:31 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-08-11 13:05:31 +0200
commit03d414cb1847fa4bdf4b9d521d6d2c0a47766113 (patch)
tree6d43866f3485294c5498878ff77abe22ab81946d /test
parent5046defebb8e04d00489a6be070b1b7e7a49ce84 (diff)
downloadcolitur-03d414cb1847fa4bdf4b9d521d6d2c0a47766113.tar.gz
colitur-03d414cb1847fa4bdf4b9d521d6d2c0a47766113.zip
fix(record): derive headers and to_row from a single columns list
Make alignment impossible: both headers and to_row are derived from a single list of (name, extractor) pairs, so reordering one without the other is impossible. CSV schema cannot silently mislabel columns. Add a meaningful test that pins the header names in order, not just length. This catches column reordering regressions.
Diffstat (limited to 'test')
-rw-r--r--test/test_names.ml8
1 files changed, 7 insertions, 1 deletions
diff --git a/test/test_names.ml b/test/test_names.ml
index 3ddf79c..1649f9e 100644
--- a/test/test_names.ml
+++ b/test/test_names.ml
@@ -130,7 +130,13 @@ let test_record () =
(* A day outside a numbered week renders week as the empty string, not "0". *)
let r' = Rec.of_temporal ~rite:"ef" demo_vocab date { t with Tmp.week = None } in
Alcotest.(check string) "no week" "" r'.Rec.week;
- Alcotest.(check int) "row matches headers" (List.length Rec.headers)
+ (* Schema is pinned: headers and to_row derive from a single columns list,
+ so alignment cannot drift. Assert the column names in order. *)
+ Alcotest.(check (list string)) "headers schema"
+ [ "date"; "rite"; "season"; "week"; "weekday"; "slug"; "rank"; "colour"; "subject" ]
+ Rec.headers;
+ (* Row must be the same length and order as headers. *)
+ Alcotest.(check int) "row matches headers length" (List.length Rec.headers)
(List.length (Rec.to_row r))
let suite =