+24 -19 +/-2 browse
1 | diff --git a/core/src/db/policies.rs b/core/src/db/policies.rs |
2 | index 7179c65..ad9db4d 100644 |
3 | --- a/core/src/db/policies.rs |
4 | +++ b/core/src/db/policies.rs |
5 | @@ -68,7 +68,8 @@ mod post_policy { |
6 | /// |
7 | /// # fn do_test(config: Configuration) { |
8 | /// let db = Connection::open_or_create_db(config).unwrap().trusted(); |
9 | - /// let list_pk = db |
10 | + /// # assert!(db.list_post_policy(1).unwrap().is_none()); |
11 | + /// let list = db |
12 | /// .create_list(MailingList { |
13 | /// pk: 0, |
14 | /// name: "foobar chat".into(), |
15 | @@ -77,19 +78,23 @@ mod post_policy { |
16 | /// description: None, |
17 | /// archive_url: None, |
18 | /// }) |
19 | - /// .unwrap() |
20 | - /// .pk; |
21 | - /// db.set_list_post_policy(PostPolicy { |
22 | - /// pk: 0, |
23 | - /// list: list_pk, |
24 | - /// announce_only: false, |
25 | - /// subscription_only: true, |
26 | - /// approval_needed: false, |
27 | - /// open: false, |
28 | - /// custom: false, |
29 | - /// }) |
30 | - /// .unwrap(); |
31 | - /// db.remove_list_post_policy(1, 1).unwrap(); |
32 | + /// .unwrap(); |
33 | + /// |
34 | + /// # assert!(db.list_post_policy(list.pk()).unwrap().is_none()); |
35 | + /// let pol = db |
36 | + /// .set_list_post_policy(PostPolicy { |
37 | + /// pk: -1, |
38 | + /// list: list.pk(), |
39 | + /// announce_only: false, |
40 | + /// subscription_only: true, |
41 | + /// approval_needed: false, |
42 | + /// open: false, |
43 | + /// custom: false, |
44 | + /// }) |
45 | + /// .unwrap(); |
46 | + /// # assert_eq!(db.list_post_policy(list.pk()).unwrap().as_ref(), Some(&pol)); |
47 | + /// db.remove_list_post_policy(list.pk(), pol.pk()).unwrap(); |
48 | + /// # assert!(db.list_post_policy(list.pk()).unwrap().is_none()); |
49 | /// # } |
50 | /// # do_test(config); |
51 | /// ``` |
52 | diff --git a/core/src/models.rs b/core/src/models.rs |
53 | index 0fda00d..9cdcfc7 100644 |
54 | --- a/core/src/models.rs |
55 | +++ b/core/src/models.rs |
56 | @@ -321,7 +321,7 @@ impl MailingList { |
57 | } |
58 | |
59 | /// A mailing list subscription entry. |
60 | - #[derive(Debug, Clone, Deserialize, Serialize)] |
61 | + #[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)] |
62 | pub struct ListSubscription { |
63 | /// Database primary key. |
64 | pub pk: i64, |
65 | @@ -383,7 +383,7 @@ impl ListSubscription { |
66 | /// A mailing list post policy entry. |
67 | /// |
68 | /// Only one of the boolean flags must be set to true. |
69 | - #[derive(Debug, Clone, Deserialize, Serialize)] |
70 | + #[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)] |
71 | pub struct PostPolicy { |
72 | /// Database primary key. |
73 | pub pk: i64, |
74 | @@ -412,7 +412,7 @@ impl std::fmt::Display for PostPolicy { |
75 | } |
76 | |
77 | /// A mailing list owner entry. |
78 | - #[derive(Debug, Clone, Deserialize, Serialize)] |
79 | + #[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)] |
80 | pub struct ListOwner { |
81 | /// Database primary key. |
82 | pub pk: i64, |
83 | @@ -488,7 +488,7 @@ impl std::fmt::Display for Post { |
84 | /// A mailing list subscription policy entry. |
85 | /// |
86 | /// Only one of the policy boolean flags must be set to true. |
87 | - #[derive(Debug, Clone, Deserialize, Serialize)] |
88 | + #[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)] |
89 | pub struct SubscriptionPolicy { |
90 | /// Database primary key. |
91 | pub pk: i64, |
92 | @@ -536,7 +536,7 @@ impl std::fmt::Display for Account { |
93 | } |
94 | |
95 | /// A mailing list subscription candidate. |
96 | - #[derive(Debug, Clone, Deserialize, Serialize)] |
97 | + #[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)] |
98 | pub struct ListCandidateSubscription { |
99 | /// Database primary key. |
100 | pub pk: i64, |