ingraph 0.1.0

A declaration-driven indexing framework: records and nodes are written as Rust types, and the storage rows, the dataflow between them and the GraphQL query surface are emitted from the declaration.
Documentation
use super::Enablement;

#[test]
fn a_deployment_that_names_nothing_launches_nothing() {
  // THE CATALOG PRINCIPLE, at its floor: the empty document is a legal deployment, and it starts
  // no node at all. THE MUTATION this pins is the inversion the launch floor shipped with — read
  // an unmentioned node as ENABLED and every catalog launches whole, which is the opposite of the
  // ruled law.
  let sleeping = Enablement::new();
  assert!(!sleeping.is_enabled("decode"));
  assert!(!sleeping.is_enabled("anything at all"));
  assert_eq!(sleeping.names().count(), 0);
}

#[test]
fn a_node_launches_by_being_named() {
  let enablement = Enablement::new().launching("decode");
  assert!(enablement.is_enabled("decode"));
  assert_eq!(enablement.names().collect::<Vec<_>>(), ["decode"]);
}

#[test]
fn naming_is_the_only_axis_there_is() {
  // THE MUTATION this pins is the soft switch coming back: with one axis, a node is dark iff it
  // was never named, so there is no second state a deployment could put one in and no second fix
  // a refusal could have to advise.
  let enablement = Enablement::new().launching("decode");
  assert!(!enablement.is_enabled("captions"));
  assert_eq!(enablement.names().count(), 1);
}

#[test]
fn one_node_is_named_once_however_many_layers_named_it() {
  // A deployment states a node once. Where a programmatic one states it twice — a layer merged
  // over another — the name is mentioned once either way, and the node runs.
  let enablement = Enablement::new().launching("decode").launching("decode");
  assert!(enablement.is_enabled("decode"));
  assert_eq!(enablement.names().count(), 1);
}

#[test]
fn the_spine_bridges_through_presence_alone() {
  use crate::NodeSection;

  // What the emitted spine folds through: one call per declared mount, carrying the `Option` the
  // document left there. A written section launches; an absent one says nothing more than that.
  let written = NodeSection::new(8_usize);
  let enablement = Enablement::new()
    .mounted("decode", Some(&written))
    .mounted("captions", None::<&NodeSection<usize>>);
  assert!(enablement.is_enabled("decode"));
  assert!(!enablement.is_enabled("captions"));
  assert_eq!(enablement.names().collect::<Vec<_>>(), ["decode"]);
}