Skip to main content

reinhardt_conf/settings/
contacts.rs

1//! Contact settings fragment
2//!
3//! Administrator and manager contact information for notifications.
4
5use super::Contact;
6use reinhardt_core::macros::settings;
7use serde::{Deserialize, Serialize};
8
9/// Administrator and manager contact information.
10///
11/// Used for error notifications and broken link notifications.
12#[settings(fragment = true, section = "contacts")]
13#[derive(Clone, Debug, Default, Serialize, Deserialize)]
14pub struct ContactSettings {
15	/// List of administrator contacts.
16	#[serde(default)]
17	pub admins: Vec<Contact>,
18	/// List of manager contacts.
19	#[serde(default)]
20	pub managers: Vec<Contact>,
21}
22
23#[cfg(test)]
24mod tests {
25	use super::*;
26	use crate::settings::Contact;
27	use crate::settings::fragment::SettingsFragment;
28	use rstest::rstest;
29
30	#[rstest]
31	fn test_contact_settings_section() {
32		// Arrange / Act / Assert
33		assert_eq!(ContactSettings::section(), "contacts");
34	}
35
36	#[rstest]
37	fn test_contact_settings_default() {
38		// Arrange / Act
39		let settings = ContactSettings::default();
40
41		// Assert
42		assert!(settings.admins.is_empty());
43		assert!(settings.managers.is_empty());
44	}
45
46	#[rstest]
47	fn test_contact_settings_with_contacts() {
48		// Arrange
49		let settings = ContactSettings {
50			admins: vec![Contact::new("Admin", "admin@example.com")],
51			managers: vec![],
52		};
53
54		// Act / Assert
55		assert_eq!(settings.admins.len(), 1);
56		assert_eq!(settings.admins[0].name, "Admin");
57	}
58}