malbox_plugin_sdk/
testkit.rs1#![cfg(any(test, feature = "testkit"))]
11
12use crate::context::Context;
13use malbox_plugin_transport::traits::TransportEmitter;
14use std::collections::HashMap;
15use std::path::PathBuf;
16use std::sync::Arc;
17
18impl Context {
19 pub fn test_new(emitter: Arc<dyn TransportEmitter + Send + Sync>) -> Context {
22 Context::new(
23 0,
24 PathBuf::new(),
25 HashMap::new(),
26 emitter,
27 None,
28 #[cfg(feature = "guest")]
29 None,
30 )
31 }
32
33 pub fn test_new_with_tx(
36 emitter: Arc<dyn TransportEmitter + Send + Sync>,
37 tx: crate::context::ResultSender,
38 ) -> Context {
39 Context::new(
40 0,
41 PathBuf::new(),
42 HashMap::new(),
43 emitter,
44 Some(tx),
45 #[cfg(feature = "guest")]
46 None,
47 )
48 }
49
50 pub fn test_new_full(
52 task_id: i32,
53 sample_path: PathBuf,
54 config: HashMap<String, String>,
55 emitter: Arc<dyn TransportEmitter + Send + Sync>,
56 result_tx: Option<crate::context::ResultSender>,
57 ) -> Context {
58 Context::new(
59 task_id,
60 sample_path,
61 config,
62 emitter,
63 result_tx,
64 #[cfg(feature = "guest")]
65 None,
66 )
67 }
68}