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 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'test_utils/src/git.rs') 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()?; -- cgit v1.2.3