Files
codex-proxy-rs/backend/crates/gateway-admin/tests/model/retention.rs
T
f61995e61d feat(settings): remove request history retention cap (#702)
* feat(settings): remove request history retention cap

Allow positive retention days beyond 31 throughout the form, domain rules,
and database constraint. Keep the existing default and saved settings.
Bound cleanup and account usage queries by stored data so large retention
windows remain safe without expanding empty history.

Co-authored-by: Codex <noreply@openai.com>

* test(admin): align retention policy coverage with positive windows

Accept long request retention windows while preserving zero rejection
for each target and independent event and audit retention settings.

Co-authored-by: Codex <noreply@openai.com>

---------

Co-authored-by: Zyy <zyycn@users.noreply.github.com>
Co-authored-by: Codex <noreply@openai.com>
2026-11-13 17:29:21 +08:00

21 lines
783 B
Rust

//! 验证历史保留窗口的有效范围与各类数据的独立配置
use gateway_admin::model::retention::{RetentionPolicy, RetentionTarget};
#[test]
fn retention_policy_rejects_zero_for_each_target() {
for (usage, ops, audit) in [(0, 1, 1), (1, 0, 1), (1, 1, 0)] {
assert!(RetentionPolicy::try_new(usage, ops, audit).is_err());
}
}
#[test]
fn request_retention_accepts_positive_windows_without_changing_other_targets() {
for days in [1, 31, 32, 365, 3650, u32::MAX] {
let policy = RetentionPolicy::try_new(days, 30, 90).unwrap();
assert_eq!(policy.days(RetentionTarget::ModelRequests), days);
assert_eq!(policy.days(RetentionTarget::OpsEvents), 30);
assert_eq!(policy.days(RetentionTarget::AdminAuditEvents), 90);
}
}