MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / new

Method new

libatomic/tests/review_workflow_service_test.rs:28–90  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26
27impl Fixture {
28 fn new() -> Self {
29 let dir = tempfile::tempdir().unwrap();
30 let repo = Repository::init(dir.path()).unwrap();
31 repo.init_vault().unwrap();
32 std::fs::write(dir.path().join("lib.rs"), "pub fn answer() -> u8 { 42 }\n").unwrap();
33 let wc = repo.require_working_copy_id().unwrap();
34 repo.add(wc, "lib.rs", TrackingOptions::default()).unwrap();
35 repo.record(
36 wc,
37 ChangeHeader::new("review service fixture"),
38 RecordOptions::new().with_all(true).enrich_kg(false),
39 )
40 .unwrap();
41 let source = repo
42 .vault_intent_create(IntentCreateOptions {
43 title: "Answer is forty-two".into(),
44 priority: None,
45 assignee: None,
46 labels: vec![],
47 session_id: None,
48 turn_id: None,
49 kind: None,
50 })
51 .unwrap();
52 repo.vault_intent_update(&source.id, IntentUpdateOptions {
53 content: Some(format!(":::why\nExpose the answer.\n:::\n:::acceptance-criterion{{#{}-ac-1 status=met verifiedBy=fixture evidence=lib.rs}}\nThe answer is 42.\n:::\n:::task{{#{}-1 status=done criteria={}-ac-1}}\nImplement it.\n:::\n", source.uid, source.uid, source.uid)),
54 status: Some("needs-review".into()), force: true, ..Default::default()
55 }).unwrap();
56 let pair = KeyPair::generate();
57 let identity = Identity::new("review-service-fixture", &pair);
58 IdentityStore::open(&repo.dot_dir().join("identities"))
59 .unwrap()
60 .save_with_keypair(&identity, &pair, None)
61 .unwrap();
62 // Only the isolated child uses a default credential store. Other tests
63 // neither mutate process environment nor touch real user credentials.
64 if std::env::var_os("ATOMIC_REVIEW_SERVICE_CHILD").is_some() {
65 let config = PathBuf::from(std::env::var_os("ATOMIC_CONFIG_DIR").unwrap());
66 IdentityStore::open(&config.join("identities"))
67 .unwrap()
68 .save_with_keypair(&identity, &pair, None)
69 .unwrap();
70 }
71 let inputs = bridge::read_intent(&repo, &source.id).unwrap();
72 let signed =
73 atomic_canonical::lift_and_attest(&inputs.frontmatter, &inputs.body, &identity, &pair)
74 .unwrap();
75 let path = bridge::attestation_vault_path(&repo, &source.id).unwrap();
76 repo.vault_store(
77 &path,
78 VaultEntryType::Attestation,
79 serde_json::to_vec(&signed).unwrap(),
80 json!({"sourceContentHash":bridge::source_content_hash(&inputs)}).to_string(),
81 )
82 .unwrap();
83 repo.vault_materialize(&path).unwrap();
84 Self {
85 view: repo.current_view().into(),

Callers

nothing calls this directly

Calls 15

lift_and_attestFunction · 0.85
enrich_kgMethod · 0.80
vault_intent_createMethod · 0.80
vault_intent_updateMethod · 0.80
save_with_keypairMethod · 0.80
vault_storeMethod · 0.80
vault_materializeMethod · 0.80
writeFunction · 0.70
initFunction · 0.50
openFunction · 0.50
read_intentFunction · 0.50

Tested by

no test coverage detected