pact_plugin_driver/
test_context.rs1use std::cell::RefCell;
4
5thread_local! {
6 static CURRENT_TEST_RUN_ID: RefCell<Option<String>> = const { RefCell::new(None) };
7}
8
9pub fn set_test_run_id(id: Option<String>) {
15 CURRENT_TEST_RUN_ID.with(|cell| *cell.borrow_mut() = id);
16}
17
18pub fn current_test_run_id() -> Option<String> {
20 CURRENT_TEST_RUN_ID.with(|cell| cell.borrow().clone())
21}
22
23pub(crate) fn current_test_context() -> Option<prost_types::Struct> {
26 current_test_run_id().map(|id| {
27 let mut fields = ::std::collections::BTreeMap::new();
28 fields.insert(
29 "testRunId".to_string(),
30 prost_types::Value {
31 kind: Some(prost_types::value::Kind::StringValue(id)),
32 },
33 );
34 prost_types::Struct { fields }
35 })
36}