diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-07-19 20:38:00 +0100 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-07-19 20:38:00 +0100 |
| commit | ab1214060a7a2d55068a7ccc9c7f6a04fd7d5aa2 (patch) | |
| tree | e561bcc093d393c2d7056a6d6c5f52e886eead27 /test_utils/src/git.rs | |
| parent | 2e54dd09a1a3b42903eee00adf4472d8b679dcb1 (diff) | |
feat: intergrate `fetch` into `send`
reworking the tests and test suite as appropriate
Diffstat (limited to 'test_utils/src/git.rs')
| -rw-r--r-- | test_utils/src/git.rs | 26 |
1 files changed, 25 insertions, 1 deletions
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}; | |||
| 5 | 5 | ||
| 6 | use anyhow::{Context, Result}; | 6 | use anyhow::{Context, Result}; |
| 7 | use git2::{Oid, RepositoryInitOptions, Signature, Time}; | 7 | use git2::{Oid, RepositoryInitOptions, Signature, Time}; |
| 8 | use nostr::nips::nip01::Coordinate; | ||
| 9 | use nostr_sdk::{Kind, ToBech32}; | ||
| 10 | |||
| 11 | use crate::{generate_repo_ref_event, REPOSITORY_KIND}; | ||
| 8 | 12 | ||
| 9 | pub struct GitTestRepo { | 13 | pub struct GitTestRepo { |
| 10 | pub dir: PathBuf, | 14 | pub dir: PathBuf, |
| @@ -13,7 +17,24 @@ pub struct GitTestRepo { | |||
| 13 | 17 | ||
| 14 | impl Default for GitTestRepo { | 18 | impl Default for GitTestRepo { |
| 15 | fn default() -> Self { | 19 | fn default() -> Self { |
| 16 | Self::new("main").unwrap() | 20 | let repo_event = generate_repo_ref_event(); |
| 21 | let coordinate = Coordinate { | ||
| 22 | kind: Kind::Custom(REPOSITORY_KIND), | ||
| 23 | public_key: repo_event.author(), | ||
| 24 | identifier: repo_event.identifier().unwrap().to_string(), | ||
| 25 | relays: vec![ | ||
| 26 | "ws://localhost:8055".to_string(), | ||
| 27 | "ws://localhost:8056".to_string(), | ||
| 28 | ], | ||
| 29 | }; | ||
| 30 | |||
| 31 | let repo = Self::new("main").unwrap(); | ||
| 32 | let _ = repo | ||
| 33 | .git_repo | ||
| 34 | .config() | ||
| 35 | .unwrap() | ||
| 36 | .set_str("nostr.repo", &coordinate.to_bech32().unwrap()); | ||
| 37 | repo | ||
| 17 | } | 38 | } |
| 18 | } | 39 | } |
| 19 | impl GitTestRepo { | 40 | impl GitTestRepo { |
| @@ -33,6 +54,9 @@ impl GitTestRepo { | |||
| 33 | git_repo, | 54 | git_repo, |
| 34 | }) | 55 | }) |
| 35 | } | 56 | } |
| 57 | pub fn without_repo_in_git_config() -> Self { | ||
| 58 | Self::new("main").unwrap() | ||
| 59 | } | ||
| 36 | 60 | ||
| 37 | pub fn initial_commit(&self) -> Result<Oid> { | 61 | pub fn initial_commit(&self) -> Result<Oid> { |
| 38 | let oid = self.git_repo.index()?.write_tree()?; | 62 | let oid = self.git_repo.index()?.write_tree()?; |