Add destructive confirmation and import guidance
This commit is contained in:
1 parent
ef2912855b
commit
5447e1bad0
29 files changed
+1099
-24
No files matched your search
@@ -14,6 +14,7 @@ pub struct RuntimeRequestContext {
|
||||
pub correlation_id: String,
|
||||
pub response_cache_scope: Option<ResponseCacheScope>,
|
||||
pub metering_context: Option<MeteringContext>,
|
||||
pub confirmation_token: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
@@ -30,6 +31,7 @@ impl RuntimeRequestContext {
|
||||
correlation_id: correlation_id.into(),
|
||||
response_cache_scope: None,
|
||||
metering_context: None,
|
||||
confirmation_token: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +80,15 @@ impl RuntimeRequestContext {
|
||||
pub fn metering_context(&self) -> Option<&MeteringContext> {
|
||||
self.metering_context.as_ref()
|
||||
}
|
||||
|
||||
pub fn with_confirmation_token(mut self, token: impl Into<String>) -> Self {
|
||||
self.confirmation_token = Some(token.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn confirmation_token(&self) -> Option<&str> {
|
||||
self.confirmation_token.as_deref()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ResponseCacheScope> for crank_core::ResponseCacheScope {
|
||||
@@ -142,6 +153,7 @@ mod tests {
|
||||
assert_eq!(context.request_id, "req_123");
|
||||
assert_eq!(context.correlation_id, "req_123");
|
||||
assert!(context.response_cache_scope.is_none());
|
||||
assert!(context.confirmation_token.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -167,4 +179,12 @@ mod tests {
|
||||
assert_eq!(metering.agent_id, None);
|
||||
assert_eq!(metering.source, InvocationSource::AdminTestRun);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn attaches_confirmation_token() {
|
||||
let context =
|
||||
RuntimeRequestContext::from_request_id("req_123").with_confirmation_token("ct_123");
|
||||
|
||||
assert_eq!(context.confirmation_token(), Some("ct_123"));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user