0e8f1ca03a
Добавить структурированные журналы, метрики, трассировку и безопасный канал критических ошибок. Усилить границы рантайма, тесты, проверку зависимостей и сценарии развёртывания.
34 lines
1.2 KiB
Rust
34 lines
1.2 KiB
Rust
use crank_observability::{CriticalErrorCategory, SentryConfig, SentryConfigError};
|
|
|
|
#[test]
|
|
fn missing_or_blank_dsn_disables_critical_error_channel() {
|
|
assert!(!SentryConfig::parse(None).expect("missing DSN").enabled());
|
|
assert!(!SentryConfig::parse(Some("")).expect("empty DSN").enabled());
|
|
assert!(
|
|
!SentryConfig::parse(Some(" "))
|
|
.expect("blank DSN")
|
|
.enabled()
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn invalid_explicit_dsn_is_rejected_without_echoing_the_value() {
|
|
let secret_value = "not-a-dsn?token=control-secret";
|
|
let error = SentryConfig::parse(Some(secret_value)).expect_err("invalid DSN must fail");
|
|
|
|
assert!(matches!(error, SentryConfigError::InvalidDsn));
|
|
assert!(!error.to_string().contains(secret_value));
|
|
assert!(!error.to_string().contains("control-secret"));
|
|
}
|
|
|
|
#[test]
|
|
fn critical_error_categories_are_closed_and_stable() {
|
|
assert_eq!(CriticalErrorCategory::Panic.as_str(), "panic");
|
|
assert_eq!(CriticalErrorCategory::Startup.as_str(), "startup");
|
|
assert_eq!(CriticalErrorCategory::Internal.as_str(), "internal");
|
|
assert_eq!(
|
|
CriticalErrorCategory::DataIntegrity.as_str(),
|
|
"data_integrity"
|
|
);
|
|
}
|