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

Function printable_attachment

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

Source from the content-addressed store, hash-verified

65
66#[test]
67fn printable_attachment() {
68 let mut report = create_report()
69 .attach(PrintableA(10))
70 .attach(PrintableB(20));
71
72 let flow = report.frames_mut(|frame| {
73 let source = frame
74 .sources_mut()
75 .first_mut()
76 .expect("No source frame found");
77 let attachment = source
78 .downcast_mut::<PrintableA>()
79 .expect("Wrong source frame");
80 attachment.0 += 10;
81 ControlFlow::Break(())
82 });
83 assert!(flow.is_break(), "No frame found");
84
85 let frame = report.frames().next().expect("No frame found");
86 assert_eq!(frame.sources().len(), 1);
87 let source = frame.sources().first().expect("No source frame found");
88 let attachment = source
89 .downcast_ref::<PrintableA>()
90 .expect("Wrong source frame");
91 assert_eq!(attachment.0, 20);
92}
93
94#[test]
95fn context() {

Callers

nothing calls this directly

Calls 10

PrintableAClass · 0.85
PrintableBClass · 0.85
frames_mutMethod · 0.80
sources_mutMethod · 0.80
framesMethod · 0.80
sourcesMethod · 0.80
create_reportFunction · 0.70
attachMethod · 0.45
expectMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected