Move admin API error tests out of source
Deploy / deploy (push) Successful in 1m34s
CI / Rust Checks (push) Failing after 5m3s
CI / Frontend E2E (push) Has been skipped
CI / Deployment Manifests (push) Has been skipped
CI / UI Checks (push) Has been skipped

This commit is contained in:
github-ops
2026-06-20 20:52:19 +00:00
parent 80cbb9cda1
commit 6a952f983f
3 changed files with 56 additions and 59 deletions
-59
View File
@@ -448,62 +448,3 @@ pub fn runtime_error_context(error: &RuntimeError) -> Option<Value> {
_ => None,
}
}
#[cfg(test)]
mod tests {
use serde_json::json;
use super::{runtime_error_context, runtime_test_failure};
use crank_runtime::RuntimeError;
#[test]
fn runtime_test_failure_includes_structured_context() {
let payload = runtime_test_failure(&RuntimeError::InvalidPreparedRequest {
field: "request.headers".to_owned(),
reason: "must be an object".to_owned(),
});
assert_eq!(payload["code"], "runtime_request_error");
assert_eq!(
payload["context"],
json!({
"field": "request.headers",
"reason": "must be an object"
})
);
}
#[test]
fn runtime_error_context_includes_secret_crypto_operation() {
let context = runtime_error_context(&RuntimeError::SecretCrypto {
operation: "decode secret envelope",
details: "bad base64".to_owned(),
})
.unwrap();
assert_eq!(
context,
json!({
"operation": "decode secret envelope",
"details": "bad base64"
})
);
}
#[test]
fn runtime_test_failure_includes_runtime_overload_context() {
let payload = runtime_test_failure(&RuntimeError::ConcurrencyLimitExceeded {
kind: "window",
limit: 16,
});
assert_eq!(payload["code"], "runtime_overloaded");
assert_eq!(
payload["context"],
json!({
"kind": "window",
"limit": 16
})
);
}
}
+2
View File
@@ -0,0 +1,2 @@
#[path = "unit/error.rs"]
mod error;
+54
View File
@@ -0,0 +1,54 @@
use admin_api::error::{runtime_error_context, runtime_test_failure};
use crank_runtime::RuntimeError;
use serde_json::json;
#[test]
fn runtime_test_failure_includes_structured_context() {
let payload = runtime_test_failure(&RuntimeError::InvalidPreparedRequest {
field: "request.headers".to_owned(),
reason: "must be an object".to_owned(),
});
assert_eq!(payload["code"], "runtime_request_error");
assert_eq!(
payload["context"],
json!({
"field": "request.headers",
"reason": "must be an object"
})
);
}
#[test]
fn runtime_error_context_includes_secret_crypto_operation() {
let context = runtime_error_context(&RuntimeError::SecretCrypto {
operation: "decode secret envelope",
details: "bad base64".to_owned(),
})
.unwrap();
assert_eq!(
context,
json!({
"operation": "decode secret envelope",
"details": "bad base64"
})
);
}
#[test]
fn runtime_test_failure_includes_runtime_overload_context() {
let payload = runtime_test_failure(&RuntimeError::ConcurrencyLimitExceeded {
kind: "window",
limit: 16,
});
assert_eq!(payload["code"], "runtime_overloaded");
assert_eq!(
payload["context"],
json!({
"kind": "window",
"limit": 16
})
);
}