diff options
Diffstat (limited to 'test_utils/src/git.rs')
| -rw-r--r-- | test_utils/src/git.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test_utils/src/git.rs b/test_utils/src/git.rs index ab21f38..a18f81c 100644 --- a/test_utils/src/git.rs +++ b/test_utils/src/git.rs | |||
| @@ -282,6 +282,30 @@ impl GitTestRepo { | |||
| 282 | branch.set_upstream(Some(&format!("origin/{branch_name}")))?; | 282 | branch.set_upstream(Some(&format!("origin/{branch_name}")))?; |
| 283 | self.checkout(branch_name) | 283 | self.checkout(branch_name) |
| 284 | } | 284 | } |
| 285 | |||
| 286 | /// Set nostr.repo git config to point to a specific pubkey's coordinate. | ||
| 287 | /// Used for State D/E tests where the coordinate points to another user. | ||
| 288 | pub fn set_nostr_repo_coordinate( | ||
| 289 | &self, | ||
| 290 | pubkey: &nostr::PublicKey, | ||
| 291 | identifier: &str, | ||
| 292 | relays: &[&str], | ||
| 293 | ) { | ||
| 294 | let relay_urls: Vec<nostr::RelayUrl> = relays | ||
| 295 | .iter() | ||
| 296 | .map(|r| nostr::RelayUrl::parse(r).unwrap()) | ||
| 297 | .collect(); | ||
| 298 | let coordinate = Nip19Coordinate { | ||
| 299 | coordinate: Coordinate::new(nostr::Kind::GitRepoAnnouncement, *pubkey) | ||
| 300 | .identifier(identifier.to_string()), | ||
| 301 | relays: relay_urls, | ||
| 302 | }; | ||
| 303 | let _ = self | ||
| 304 | .git_repo | ||
| 305 | .config() | ||
| 306 | .unwrap() | ||
| 307 | .set_str("nostr.repo", &coordinate.to_bech32().unwrap()); | ||
| 308 | } | ||
| 285 | } | 309 | } |
| 286 | 310 | ||
| 287 | impl Drop for GitTestRepo { | 311 | impl Drop for GitTestRepo { |