mirror of
https://seed.radicle.dev/rad:z6cFWeWpnZNHh9rUW8phgA3b5yGt.git
synced 2026-10-28 07:30:51 +08:00
Two of the tests in radicle-git-ext and radicle-surf relied on using the Git repository itself. This can end up being an issue when sandboxing is involved. This improves the situation by being able to generate commit data to add to a temporary repository. It also adds a helper for creating a local, temporary submodule for testing the submodule interactions in the radicle-surf API. Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com> X-Clacks-Overhead: GNU Terry Pratchett
31 lines
917 B
Rust
31 lines
917 B
Rust
use proptest::{collection, prop_oneof, strategy::Strategy};
|
|
use radicle_git_ext::commit::headers::Headers;
|
|
|
|
use crate::gen;
|
|
|
|
pub fn headers() -> impl Strategy<Value = Headers> {
|
|
collection::vec(prop_oneof![header(), signature()], 0..5).prop_map(|hs| {
|
|
let mut headers = Headers::new();
|
|
for (k, v) in hs {
|
|
headers.push(&k, &v);
|
|
}
|
|
headers
|
|
})
|
|
}
|
|
|
|
fn header() -> impl Strategy<Value = (String, String)> {
|
|
(prop_oneof!["test", "foo", "foobar"], gen::alphanumeric())
|
|
}
|
|
|
|
pub fn signature() -> impl Strategy<Value = (String, String)> {
|
|
("gpgsig", prop_oneof![pgp(), ssh()])
|
|
}
|
|
|
|
pub fn pgp() -> impl Strategy<Value = String> {
|
|
"-----BEGIN PGP SIGNATURE-----\r?\n([A-Za-z0-9+/=\r\n]+)\r?\n-----END PGP SIGNATURE-----"
|
|
}
|
|
|
|
pub fn ssh() -> impl Strategy<Value = String> {
|
|
"-----BEGIN SSH SIGNATURE-----\r?\n([A-Za-z0-9+/=\r\n]+)\r?\n-----END SSH SIGNATURE-----"
|
|
}
|