radicle-surf: organise tests

Reorganise the tests into module files, rather than all being in a
single file. No tests were changed in this patch.

The `serialize` flag was also not enabled in `test/Cargo.toml`. This
is enabled to ensure those tests are run moving forward.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
Fintan Halpenny
2022-11-24 12:25:31 +00:00
parent d657572dfd
commit a4ec9e07e1
12 changed files with 770 additions and 780 deletions
+33
View File
@@ -0,0 +1,33 @@
use std::str::FromStr;
use proptest::prelude::*;
use radicle_git_ext::Oid;
use radicle_surf::git::{Author, Commit};
use test_helpers::roundtrip;
#[cfg(feature = "serialize")]
proptest! {
#[test]
fn prop_test_commits(commit in commits_strategy()) {
roundtrip::json(commit)
}
}
fn commits_strategy() -> impl Strategy<Value = Commit> {
("[a-fA-F0-9]{40}", any::<String>(), any::<i64>()).prop_map(|(id, text, time)| Commit {
id: Oid::from_str(&id).unwrap(),
author: Author {
name: text.clone(),
email: text.clone(),
time: git2::Time::new(time, 0),
},
committer: Author {
name: text.clone(),
email: text.clone(),
time: git2::Time::new(time, 0),
},
message: text.clone(),
summary: text,
parents: vec![Oid::from_str(&id).unwrap(), Oid::from_str(&id).unwrap()],
})
}