diff options
| author | Pjotr <wrk@bosa.lan> | 2026-11-07 17:17:19 +0000 |
|---|---|---|
| committer | Pjotr <wrk@bosa.lan> | 2026-11-07 17:17:19 +0000 |
| commit | 2307d5e2db5ce8efae19a647bd48b4311be34607 (patch) | |
| tree | aefc0a48a38cd69fd0f38f8c163ad77ad8d8317a /tests | |
| parent | 9fa03035b9f21352c1c8b93681cc1bc1ce4cf6ff (diff) | |
| download | genenetwork4-2307d5e2db5ce8efae19a647bd48b4311be34607.tar.gz | |
version: document the provenance fields, and assert they agree
* README.md (/version): the example carries dirty/source_digest/branch, and the prose says why a stamp can lag a commit -- a binary built from a dirty tree must not claim that commit -- and that build.rs re-stamps on a commit because it watches the ref, not just .git/HEAD. * docs/www/ai-instruction.md: comparing against a clone means comparing the part before "-dirty", with source_digest for the exact build. * tests/version.rs: `dirty` mirrors the suffix, branch is non-empty, and source_digest is 16 hex digits or unknown.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/version.rs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/tests/version.rs b/tests/version.rs index 29ae4c5..0753367 100644 --- a/tests/version.rs +++ b/tests/version.rs @@ -32,7 +32,20 @@ async fn version_returns_ok_with_json_record() { assert_eq!(record["short_name"], "GN4AI"); assert_eq!(record["version"], 4.0); assert_eq!(record["release"], 1); - // date and git are set at build time (see build.rs); just check shape. + // Stamped at build time (see build.rs): check the shape, and that the + // three provenance fields agree with each other. assert_eq!(record["date"].as_str().unwrap().len(), 8); - assert!(!record["git"].as_str().unwrap().is_empty()); + let git = record["git"].as_str().unwrap(); + assert!(!git.is_empty()); + assert_eq!( + record["dirty"].as_bool().unwrap(), + git.ends_with("-dirty"), + "`dirty` mirrors the -dirty suffix: {record}" + ); + assert!(!record["branch"].as_str().unwrap().is_empty()); + let digest = record["source_digest"].as_str().unwrap(); + assert!( + digest == "unknown" || (digest.len() == 16 && digest.chars().all(|c| c.is_ascii_hexdigit())), + "a 64-bit hex digest, or unknown: {digest}" + ); } |
