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

Function opaque_attachment

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

Source from the content-addressed store, hash-verified

8
9#[test]
10fn opaque_attachment() {
11 let mut report = create_report()
12 .attach_opaque(AttachmentA(10))
13 .attach_opaque(AttachmentB(20));
14
15 let flow = report.frames_mut(|frame| {
16 let source = frame
17 .sources_mut()
18 .first_mut()
19 .expect("No source frame found");
20 let attachment = source
21 .downcast_mut::<AttachmentA>()
22 .expect("Wrong source frame");
23 attachment.0 += 10;
24 ControlFlow::Break(())
25 });
26 assert!(flow.is_break(), "No frame found");
27
28 let frame = report.frames().next().expect("No frame found");
29 assert_eq!(frame.sources().len(), 1);
30 let source = frame.sources().first().expect("No source frame found");
31 let attachment = source
32 .downcast_ref::<AttachmentA>()
33 .expect("Wrong source frame");
34 assert_eq!(attachment.0, 20);
35}
36
37#[test]
38fn sources() {

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected