From ab1214060a7a2d55068a7ccc9c7f6a04fd7d5aa2 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 19 Jul 2024 20:38:00 +0100 Subject: feat: intergrate `fetch` into `send` reworking the tests and test suite as appropriate --- test_utils/src/git.rs | 26 +++++++++++++++++++++++++- test_utils/src/lib.rs | 2 +- 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'test_utils') diff --git a/test_utils/src/git.rs b/test_utils/src/git.rs index db50165..7aa7e84 100644 --- a/test_utils/src/git.rs +++ b/test_utils/src/git.rs @@ -5,6 +5,10 @@ use std::{env::current_dir, fs, path::PathBuf}; use anyhow::{Context, Result}; use git2::{Oid, RepositoryInitOptions, Signature, Time}; +use nostr::nips::nip01::Coordinate; +use nostr_sdk::{Kind, ToBech32}; + +use crate::{generate_repo_ref_event, REPOSITORY_KIND}; pub struct GitTestRepo { pub dir: PathBuf, @@ -13,7 +17,24 @@ pub struct GitTestRepo { impl Default for GitTestRepo { fn default() -> Self { - Self::new("main").unwrap() + let repo_event = generate_repo_ref_event(); + let coordinate = Coordinate { + kind: Kind::Custom(REPOSITORY_KIND), + public_key: repo_event.author(), + identifier: repo_event.identifier().unwrap().to_string(), + relays: vec![ + "ws://localhost:8055".to_string(), + "ws://localhost:8056".to_string(), + ], + }; + + let repo = Self::new("main").unwrap(); + let _ = repo + .git_repo + .config() + .unwrap() + .set_str("nostr.repo", &coordinate.to_bech32().unwrap()); + repo } } impl GitTestRepo { @@ -33,6 +54,9 @@ impl GitTestRepo { git_repo, }) } + pub fn without_repo_in_git_config() -> Self { + Self::new("main").unwrap() + } pub fn initial_commit(&self) -> Result { let oid = self.git_repo.index()?.write_tree()?; diff --git a/test_utils/src/lib.rs b/test_utils/src/lib.rs index 2825eaa..a3ffd70 100644 --- a/test_utils/src/lib.rs +++ b/test_utils/src/lib.rs @@ -191,7 +191,7 @@ pub fn generate_repo_ref_event() -> nostr::Event { /// enough to fool event_is_patch_set_root pub fn get_pretend_proposal_root_event() -> nostr::Event { - serde_json::from_str(r#"{"id":"8cb75aa4cda10a3a0f3242dc49d36159d30b3185bf63414cf6ce17f5c14a73b1","pubkey":"f53e4bcd7a9cdef049cf6467d638a1321958acd3b71eb09823fd6fadb023d768","created_at":1714984571,"kind":1617,"tags":[["t","root"]],"content":"","sig":"6c197314b8c4c61da696dff888198333004d1ecc5d7bae2c554857f2f2b0d3ecc09369a5d8ba089c1bf89e3c6f5be40ade873fd698438ef8b303ffc6df35eb3f"}"#).unwrap() + serde_json::from_str(r#"{"id":"431e58eb8e1b4e20292d1d5bbe81d5cfb042e1bc165de32eddfdd52245a4cce4","pubkey":"f53e4bcd7a9cdef049cf6467d638a1321958acd3b71eb09823fd6fadb023d768","created_at":1721404213,"kind":1617,"tags":[["a","30617:ba882566eff14f3baa976103998c452d27fe95b65a796a6a9f92628bced76fe5:9ee507fc4357d7ee16a5d8901bedcd103f23c17d-consider-it-random"],["a","30617:f53e4bcd7a9cdef049cf6467d638a1321958acd3b71eb09823fd6fadb023d768:9ee507fc4357d7ee16a5d8901bedcd103f23c17d-consider-it-random"],["r","9ee507fc4357d7ee16a5d8901bedcd103f23c17d"],["t","cover-letter"],["alt","git patch cover letter: exampletitle"],["t","root"],["e","8cb75aa4cda10a3a0f3242dc49d36159d30b3185bf63414cf6ce17f5c14a73b1","","mention"],["branch-name","feature"],["p","ba882566eff14f3baa976103998c452d27fe95b65a796a6a9f92628bced76fe5"],["p","f53e4bcd7a9cdef049cf6467d638a1321958acd3b71eb09823fd6fadb023d768"]],"content":"From fe973a840fba2a8ab37dd505c154854a69a6505c Mon Sep 17 00:00:00 2001\nSubject: [PATCH 0/2] exampletitle\n\nexampledescription","sig":"37d5b2338bf9fd9d598e6494ae88af9a8dbd52330cfe9d025ee55e35e2f3f55e931ba039d9f7fed8e6fc40206e47619a24f730f8eddc2a07ccfb3988a5005170"}"#).unwrap() } /// wrapper for a cli testing tool - currently wraps rexpect and dialoguer -- cgit v1.2.3