MCPcopy Create free account
hub / github.com/hashintel/hash / sources

Function sources

libs/error-stack/tests/test_frame.rs:38–64  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

36
37#[test]
38fn sources() {
39 let mut report_a = create_report().attach_opaque(AttachmentA(10)).expand();
40 let report_b = create_report().attach_opaque(AttachmentA(20));
41 report_a.push(report_b);
42 let mut report = report_a.attach_opaque(AttachmentB(30));
43
44 let flow = report.frames_mut(|frame| {
45 assert_eq!(frame.sources().len(), 2);
46
47 for source in frame.sources_mut() {
48 let attachment = source
49 .downcast_mut::<AttachmentA>()
50 .expect("Wrong source frame");
51 attachment.0 += 5;
52 }
53 ControlFlow::Break(())
54 });
55 assert!(flow.is_break(), "No frames");
56
57 let frame = report.frames().next().expect("No frames");
58 for (source, expect) in zip(frame.sources(), [15, 25]) {
59 let attachment = source
60 .downcast_ref::<AttachmentA>()
61 .expect("Wrong source frame");
62 assert_eq!(attachment.0, expect);
63 }
64}
65
66#[test]
67fn printable_attachment() {

Callers

nothing calls this directly

Calls 12

AttachmentAClass · 0.85
AttachmentBClass · 0.85
expandMethod · 0.80
frames_mutMethod · 0.80
sources_mutMethod · 0.80
framesMethod · 0.80
sourcesMethod · 0.80
create_reportFunction · 0.70
pushMethod · 0.65
attach_opaqueMethod · 0.45
expectMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected