krz/orgo

Lightning fast org-mode static site generator.

clone: git clone https://gitbay.org/krz/orgo.git

v0.20.0: tests/harness.rs · raw

 1//! Proves the test harness works end to end while the pipeline is still stubbed.
 2//!
 3//! Two layers, matching the spec's testing philosophy (§5):
 4//! - a plain unit test on the one real function (`content_hash`);
 5//! - an `insta` JSON snapshot of a hand-built element-tree value, standing in for the
 6//!   element-tree snapshots the parser will produce from Phase 1 onward.
 7
 8use orgo::model::{Link, LinkTarget, Object};
 9use orgo::parser::content_hash;
10
11#[test]
12fn content_hash_is_deterministic_blake3() {
13    let a = content_hash(b"hello\n");
14    let b = content_hash(b"hello\n");
15    let c = content_hash(b"goodbye\n");
16    assert_eq!(a, b, "same bytes must hash identically");
17    assert_ne!(a, c, "different bytes must hash differently");
18    // blake3 is 32 bytes.
19    assert_eq!(a.0.len(), 32);
20}
21
22#[test]
23fn element_tree_json_snapshot() {
24    // A small inline-object tree built by hand — the shape the parser will emit.
25    let tree = vec![
26        Object::Text("see ".into()),
27        Object::Bold(vec![Object::Text("bold".into())]),
28        Object::Link(Link {
29            target: LinkTarget::CustomId("first".into()),
30            description: Some(vec![Object::Text("the first heading".into())]),
31        }),
32    ];
33    insta::assert_json_snapshot!(tree);
34}