mirror of
https://github.com/soywod/himalaya.git
synced 2024-07-03 07:55:13 +00:00
fix unit tests
This commit is contained in:
parent
faeda95978
commit
5cb247169a
|
@ -14,7 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Removed account configurations flatten level in order to improve diagnostic errors, due to a [bug](https://github.com/toml-rs/toml/issues/589#issuecomment-1872345017) in clap. **This means that accounts need to be prefixed by `accounts`: `[my-account]` becomes `[accounts.my-account]`**. It also opens doors for interface-specific configurations.
|
- Removed account configurations flatten level in order to improve diagnostic errors, due to a [bug](https://github.com/toml-rs/toml/issues/589#issuecomment-1872345017) in clap. **This means that accounts need to be prefixed by `accounts`: `[my-account]` becomes `[accounts.my-account]`**. It also opens doors for interface-specific configurations.
|
||||||
- Rolled back cargo feature additions from the previous release. It was a mistake: the amount of features was too big, the code (both CLI and lib) was too hard to maintain. Cargo features kept: `imap`, `maildir`, `notmuch`, `account-sync`, `account-discovery`, `pgp-gpg`, `pgp-commands` and `pgp-native`.
|
- Rolled back cargo feature additions from the previous release. It was a mistake: the amount of features was too big, the code (both CLI and lib) was too hard to maintain. Cargo features kept: `imap`, `maildir`, `notmuch`, `smtp`, `sendmail`, `account-sync`, `account-discovery`, `pgp-gpg`, `pgp-commands` and `pgp-native`.
|
||||||
- Improved pre and post edit choices interaction [#58].
|
- Improved pre and post edit choices interaction [#58].
|
||||||
- Improved account synchronization performances, making it 50% faster than `mbsync` and 370% faster than `OfflineIMAP`.
|
- Improved account synchronization performances, making it 50% faster than `mbsync` and 370% faster than `OfflineIMAP`.
|
||||||
- Changed `envelope.watch.{event}.{hook}`: hooks can now be cumulated. For example it is possible to send a system notification and execute a shell command when receiving a new envelope:
|
- Changed `envelope.watch.{event}.{hook}`: hooks can now be cumulated. For example it is possible to send a system notification and execute a shell command when receiving a new envelope:
|
||||||
|
|
|
@ -106,64 +106,66 @@ fn pretty_serialize(config: &TomlConfig) -> Result<String> {
|
||||||
let mut doc: Document = toml::to_string(&config)?.parse()?;
|
let mut doc: Document = toml::to_string(&config)?.parse()?;
|
||||||
|
|
||||||
doc.iter_mut().for_each(|(_, item)| {
|
doc.iter_mut().for_each(|(_, item)| {
|
||||||
set_table_dotted(item, "folder");
|
if let Some(item) = item.as_table_mut() {
|
||||||
if let Some(item) = get_table_mut(item, "folder") {
|
item.iter_mut().for_each(|(_, item)| {
|
||||||
set_tables_dotted(item, ["alias", "add", "list", "expunge", "purge", "delete"]);
|
set_table_dotted(item, "folder");
|
||||||
|
if let Some(item) = get_table_mut(item, "folder") {
|
||||||
|
let keys = ["alias", "add", "list", "expunge", "purge", "delete", "sync"];
|
||||||
|
set_tables_dotted(item, keys);
|
||||||
|
|
||||||
|
if let Some(item) = get_table_mut(item, "sync") {
|
||||||
|
set_tables_dotted(item, ["filter", "permissions"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
set_table_dotted(item, "envelope");
|
||||||
|
if let Some(item) = get_table_mut(item, "envelope") {
|
||||||
|
set_tables_dotted(item, ["list", "get"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
set_table_dotted(item, "flag");
|
||||||
|
if let Some(item) = get_table_mut(item, "flag") {
|
||||||
|
set_tables_dotted(item, ["add", "set", "remove"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
set_table_dotted(item, "message");
|
||||||
|
if let Some(item) = get_table_mut(item, "message") {
|
||||||
|
let keys = ["add", "send", "peek", "get", "copy", "move", "delete"];
|
||||||
|
set_tables_dotted(item, keys);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "maildir")]
|
||||||
|
set_table_dotted(item, "maildir");
|
||||||
|
|
||||||
|
#[cfg(feature = "imap")]
|
||||||
|
{
|
||||||
|
set_table_dotted(item, "imap");
|
||||||
|
if let Some(item) = get_table_mut(item, "imap") {
|
||||||
|
set_tables_dotted(item, ["passwd", "oauth2"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "notmuch")]
|
||||||
|
set_table_dotted(item, "notmuch");
|
||||||
|
|
||||||
|
#[cfg(feature = "smtp")]
|
||||||
|
{
|
||||||
|
set_table_dotted(item, "smtp");
|
||||||
|
if let Some(item) = get_table_mut(item, "smtp") {
|
||||||
|
set_tables_dotted(item, ["passwd", "oauth2"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "sendmail")]
|
||||||
|
set_table_dotted(item, "sendmail");
|
||||||
|
|
||||||
|
#[cfg(feature = "account-sync")]
|
||||||
|
set_table_dotted(item, "sync");
|
||||||
|
|
||||||
|
#[cfg(feature = "pgp")]
|
||||||
|
set_table_dotted(item, "pgp");
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
set_table_dotted(item, "envelope");
|
|
||||||
if let Some(item) = get_table_mut(item, "envelope") {
|
|
||||||
set_tables_dotted(item, ["list", "get"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
set_table_dotted(item, "flag");
|
|
||||||
if let Some(item) = get_table_mut(item, "flag") {
|
|
||||||
set_tables_dotted(item, ["add", "set", "remove"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
set_table_dotted(item, "message");
|
|
||||||
if let Some(item) = get_table_mut(item, "message") {
|
|
||||||
set_tables_dotted(
|
|
||||||
item,
|
|
||||||
["add", "send", "peek", "get", "copy", "move", "delete"],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "maildir")]
|
|
||||||
set_table_dotted(item, "maildir");
|
|
||||||
|
|
||||||
#[cfg(feature = "imap")]
|
|
||||||
{
|
|
||||||
set_table_dotted(item, "imap");
|
|
||||||
if let Some(item) = get_table_mut(item, "imap") {
|
|
||||||
set_tables_dotted(item, ["passwd", "oauth2"]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "notmuch")]
|
|
||||||
set_table_dotted(item, "notmuch");
|
|
||||||
|
|
||||||
#[cfg(feature = "smtp")]
|
|
||||||
{
|
|
||||||
set_table_dotted(item, "smtp");
|
|
||||||
if let Some(item) = get_table_mut(item, "smtp") {
|
|
||||||
set_tables_dotted(item, ["passwd", "oauth2"]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "sendmail")]
|
|
||||||
set_table_dotted(item, "sendmail");
|
|
||||||
|
|
||||||
#[cfg(feature = "account-sync")]
|
|
||||||
{
|
|
||||||
set_table_dotted(item, "sync");
|
|
||||||
if let Some(item) = get_table_mut(item, "sync") {
|
|
||||||
set_tables_dotted(item, ["strategy"]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "pgp")]
|
|
||||||
set_table_dotted(item, "pgp");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok(doc.to_string())
|
Ok(doc.to_string())
|
||||||
|
@ -213,7 +215,7 @@ mod test {
|
||||||
email: "test@localhost".into(),
|
email: "test@localhost".into(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
r#"[test]
|
r#"[accounts.test]
|
||||||
email = "test@localhost"
|
email = "test@localhost"
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
|
@ -222,7 +224,7 @@ email = "test@localhost"
|
||||||
#[cfg(feature = "account-sync")]
|
#[cfg(feature = "account-sync")]
|
||||||
#[test]
|
#[test]
|
||||||
fn pretty_serialize_sync_all() {
|
fn pretty_serialize_sync_all() {
|
||||||
use email::{account::sync::config::SyncConfig, folder::sync::FolderSyncStrategy};
|
use email::account::sync::config::SyncConfig;
|
||||||
|
|
||||||
assert_eq(
|
assert_eq(
|
||||||
TomlAccountConfig {
|
TomlAccountConfig {
|
||||||
|
@ -230,15 +232,14 @@ email = "test@localhost"
|
||||||
sync: Some(SyncConfig {
|
sync: Some(SyncConfig {
|
||||||
enable: Some(false),
|
enable: Some(false),
|
||||||
dir: Some("/tmp/test".into()),
|
dir: Some("/tmp/test".into()),
|
||||||
strategy: Some(FolderSyncStrategy::All),
|
..Default::default()
|
||||||
}),
|
}),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
r#"[test]
|
r#"[accounts.test]
|
||||||
email = "test@localhost"
|
email = "test@localhost"
|
||||||
sync.enable = false
|
sync.enable = false
|
||||||
sync.dir = "/tmp/test"
|
sync.dir = "/tmp/test"
|
||||||
sync.strategy = "all"
|
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -246,9 +247,13 @@ sync.strategy = "all"
|
||||||
#[cfg(feature = "account-sync")]
|
#[cfg(feature = "account-sync")]
|
||||||
#[test]
|
#[test]
|
||||||
fn pretty_serialize_sync_include() {
|
fn pretty_serialize_sync_include() {
|
||||||
use std::collections::HashSet;
|
use email::{
|
||||||
|
account::sync::config::SyncConfig,
|
||||||
|
folder::sync::config::{FolderSyncConfig, FolderSyncStrategy},
|
||||||
|
};
|
||||||
|
use std::collections::BTreeSet;
|
||||||
|
|
||||||
use email::{account::sync::config::SyncConfig, folder::sync::FolderSyncStrategy};
|
use crate::folder::config::FolderConfig;
|
||||||
|
|
||||||
assert_eq(
|
assert_eq(
|
||||||
TomlAccountConfig {
|
TomlAccountConfig {
|
||||||
|
@ -256,17 +261,24 @@ sync.strategy = "all"
|
||||||
sync: Some(SyncConfig {
|
sync: Some(SyncConfig {
|
||||||
enable: Some(true),
|
enable: Some(true),
|
||||||
dir: Some("/tmp/test".into()),
|
dir: Some("/tmp/test".into()),
|
||||||
strategy: Some(FolderSyncStrategy::Include(HashSet::from_iter([
|
..Default::default()
|
||||||
"test".into()
|
}),
|
||||||
]))),
|
folder: Some(FolderConfig {
|
||||||
|
sync: Some(FolderSyncConfig {
|
||||||
|
filter: FolderSyncStrategy::Include(BTreeSet::from_iter(["test".into()])),
|
||||||
|
..Default::default()
|
||||||
|
}),
|
||||||
|
..Default::default()
|
||||||
}),
|
}),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
r#"[test]
|
r#"[accounts.test]
|
||||||
email = "test@localhost"
|
email = "test@localhost"
|
||||||
sync.enable = true
|
sync.enable = true
|
||||||
sync.dir = "/tmp/test"
|
sync.dir = "/tmp/test"
|
||||||
sync.strategy.include = ["test"]
|
folder.sync.filter.include = ["test"]
|
||||||
|
folder.sync.permissions.create = true
|
||||||
|
folder.sync.permissions.delete = true
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -292,7 +304,7 @@ sync.strategy.include = ["test"]
|
||||||
}),
|
}),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
r#"[test]
|
r#"[accounts.test]
|
||||||
email = "test@localhost"
|
email = "test@localhost"
|
||||||
imap.host = "localhost"
|
imap.host = "localhost"
|
||||||
imap.port = 143
|
imap.port = 143
|
||||||
|
@ -326,7 +338,7 @@ imap.passwd.cmd = "pass show test"
|
||||||
}),
|
}),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
r#"[test]
|
r#"[accounts.test]
|
||||||
email = "test@localhost"
|
email = "test@localhost"
|
||||||
imap.host = "localhost"
|
imap.host = "localhost"
|
||||||
imap.port = 143
|
imap.port = 143
|
||||||
|
@ -361,7 +373,7 @@ imap.passwd.cmd = ["pass show test", "tr -d '[:blank:]'"]
|
||||||
}),
|
}),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
r#"[test]
|
r#"[accounts.test]
|
||||||
email = "test@localhost"
|
email = "test@localhost"
|
||||||
imap.host = "localhost"
|
imap.host = "localhost"
|
||||||
imap.port = 143
|
imap.port = 143
|
||||||
|
@ -389,7 +401,7 @@ imap.oauth2.scopes = []
|
||||||
}),
|
}),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
r#"[test]
|
r#"[accounts.test]
|
||||||
email = "test@localhost"
|
email = "test@localhost"
|
||||||
maildir.root-dir = "/tmp/test"
|
maildir.root-dir = "/tmp/test"
|
||||||
"#,
|
"#,
|
||||||
|
@ -417,7 +429,7 @@ maildir.root-dir = "/tmp/test"
|
||||||
}),
|
}),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
r#"[test]
|
r#"[accounts.test]
|
||||||
email = "test@localhost"
|
email = "test@localhost"
|
||||||
smtp.host = "localhost"
|
smtp.host = "localhost"
|
||||||
smtp.port = 143
|
smtp.port = 143
|
||||||
|
@ -451,7 +463,7 @@ smtp.passwd.cmd = "pass show test"
|
||||||
}),
|
}),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
r#"[test]
|
r#"[accounts.test]
|
||||||
email = "test@localhost"
|
email = "test@localhost"
|
||||||
smtp.host = "localhost"
|
smtp.host = "localhost"
|
||||||
smtp.port = 143
|
smtp.port = 143
|
||||||
|
@ -486,7 +498,7 @@ smtp.passwd.cmd = ["pass show test", "tr -d '[:blank:]'"]
|
||||||
}),
|
}),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
r#"[test]
|
r#"[accounts.test]
|
||||||
email = "test@localhost"
|
email = "test@localhost"
|
||||||
smtp.host = "localhost"
|
smtp.host = "localhost"
|
||||||
smtp.port = 143
|
smtp.port = 143
|
||||||
|
@ -512,7 +524,7 @@ smtp.oauth2.scopes = []
|
||||||
pgp: Some(PgpConfig::Cmds(Default::default())),
|
pgp: Some(PgpConfig::Cmds(Default::default())),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
r#"[test]
|
r#"[accounts.test]
|
||||||
email = "test@localhost"
|
email = "test@localhost"
|
||||||
pgp.backend = "cmds"
|
pgp.backend = "cmds"
|
||||||
"#,
|
"#,
|
||||||
|
|
Loading…
Reference in a new issue