core/db/policies.rs: test optional policy fetch
parent
524bc88d33
commit
154ea631c6
|
@ -68,7 +68,8 @@ mod post_policy {
|
|||
///
|
||||
/// # fn do_test(config: Configuration) {
|
||||
/// let db = Connection::open_or_create_db(config).unwrap().trusted();
|
||||
/// let list_pk = db
|
||||
/// # assert!(db.list_post_policy(1).unwrap().is_none());
|
||||
/// let list = db
|
||||
/// .create_list(MailingList {
|
||||
/// pk: 0,
|
||||
/// name: "foobar chat".into(),
|
||||
|
@ -77,19 +78,23 @@ mod post_policy {
|
|||
/// description: None,
|
||||
/// archive_url: None,
|
||||
/// })
|
||||
/// .unwrap()
|
||||
/// .pk;
|
||||
/// db.set_list_post_policy(PostPolicy {
|
||||
/// pk: 0,
|
||||
/// list: list_pk,
|
||||
/// announce_only: false,
|
||||
/// subscription_only: true,
|
||||
/// approval_needed: false,
|
||||
/// open: false,
|
||||
/// custom: false,
|
||||
/// })
|
||||
/// .unwrap();
|
||||
/// db.remove_list_post_policy(1, 1).unwrap();
|
||||
/// .unwrap();
|
||||
///
|
||||
/// # assert!(db.list_post_policy(list.pk()).unwrap().is_none());
|
||||
/// let pol = db
|
||||
/// .set_list_post_policy(PostPolicy {
|
||||
/// pk: -1,
|
||||
/// list: list.pk(),
|
||||
/// announce_only: false,
|
||||
/// subscription_only: true,
|
||||
/// approval_needed: false,
|
||||
/// open: false,
|
||||
/// custom: false,
|
||||
/// })
|
||||
/// .unwrap();
|
||||
/// # assert_eq!(db.list_post_policy(list.pk()).unwrap().as_ref(), Some(&pol));
|
||||
/// db.remove_list_post_policy(list.pk(), pol.pk()).unwrap();
|
||||
/// # assert!(db.list_post_policy(list.pk()).unwrap().is_none());
|
||||
/// # }
|
||||
/// # do_test(config);
|
||||
/// ```
|
||||
|
|
|
@ -321,7 +321,7 @@ impl MailingList {
|
|||
}
|
||||
|
||||
/// A mailing list subscription entry.
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
|
||||
pub struct ListSubscription {
|
||||
/// Database primary key.
|
||||
pub pk: i64,
|
||||
|
@ -383,7 +383,7 @@ impl ListSubscription {
|
|||
/// A mailing list post policy entry.
|
||||
///
|
||||
/// Only one of the boolean flags must be set to true.
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
|
||||
pub struct PostPolicy {
|
||||
/// Database primary key.
|
||||
pub pk: i64,
|
||||
|
@ -412,7 +412,7 @@ impl std::fmt::Display for PostPolicy {
|
|||
}
|
||||
|
||||
/// A mailing list owner entry.
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
|
||||
pub struct ListOwner {
|
||||
/// Database primary key.
|
||||
pub pk: i64,
|
||||
|
@ -488,7 +488,7 @@ impl std::fmt::Display for Post {
|
|||
/// A mailing list subscription policy entry.
|
||||
///
|
||||
/// Only one of the policy boolean flags must be set to true.
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
|
||||
pub struct SubscriptionPolicy {
|
||||
/// Database primary key.
|
||||
pub pk: i64,
|
||||
|
@ -536,7 +536,7 @@ impl std::fmt::Display for Account {
|
|||
}
|
||||
|
||||
/// A mailing list subscription candidate.
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
|
||||
pub struct ListCandidateSubscription {
|
||||
/// Database primary key.
|
||||
pub pk: i64,
|
||||
|
|
Loading…
Reference in New Issue