From 4dafb64d580c2a8584ed72c13296334ca6e070ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Mon, 27 Apr 2026 10:41:38 +0800 Subject: [PATCH] test(server): cover default module switch source (#2697) --- rustfs/src/server/module_switch.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/rustfs/src/server/module_switch.rs b/rustfs/src/server/module_switch.rs index d69832c7c..3f492542f 100644 --- a/rustfs/src/server/module_switch.rs +++ b/rustfs/src/server/module_switch.rs @@ -258,6 +258,35 @@ mod tests { ); } + #[test] + #[serial] + fn current_module_switch_snapshot_uses_defaults_when_persisted_file_is_absent() { + set_persisted_module_switches( + PersistedModuleSwitches { + notify_enabled: false, + audit_enabled: false, + }, + false, + ); + + with_vars( + [ + (rustfs_config::ENV_NOTIFY_ENABLE, None::<&str>), + (rustfs_config::ENV_AUDIT_ENABLE, None::<&str>), + ], + || { + let snapshot = current_module_switch_snapshot(); + + assert_eq!(snapshot.notify_enabled, rustfs_config::DEFAULT_NOTIFY_ENABLE); + assert_eq!(snapshot.audit_enabled, rustfs_config::DEFAULT_AUDIT_ENABLE); + assert!(!snapshot.persisted_notify_enabled); + assert!(!snapshot.persisted_audit_enabled); + assert_eq!(snapshot.notify_source, ModuleSwitchSource::Default); + assert_eq!(snapshot.audit_source, ModuleSwitchSource::Default); + }, + ); + } + #[test] #[serial] fn validate_module_switch_update_rejects_env_conflict() {