upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2024-08-01 11:56:57 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2024-08-01 11:58:43 +0100
commit777a414d368b66363090a6d38beb95c821a4077b (patch)
tree56f115536a510c64f4e9a633f767781728673433
parent640fb41902c140a63f46b6126d17416b7dccf344 (diff)
test(remote): add nostr url parse test
in prep for supporting new format
-rw-r--r--src/git_remote_helper.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/git_remote_helper.rs b/src/git_remote_helper.rs
index 7b471b1..ea220de 100644
--- a/src/git_remote_helper.rs
+++ b/src/git_remote_helper.rs
@@ -518,3 +518,37 @@ impl RepoState {
518 }) 518 })
519 } 519 }
520} 520}
521
522#[cfg(test)]
523mod tests {
524 use super::*;
525
526 mod nostr_git_url_to_repo_coordinates {
527 use nostr_sdk::PublicKey;
528
529 use super::*;
530
531 fn get_model_coordinate() -> Coordinate {
532 Coordinate {
533 identifier: "ngit".to_string(),
534 public_key: PublicKey::parse(
535 "npub15qydau2hjma6ngxkl2cyar74wzyjshvl65za5k5rl69264ar2exs5cyejr",
536 )
537 .unwrap(),
538 kind: nostr_sdk::Kind::GitRepoAnnouncement,
539 relays: vec!["wss://nos.lol".to_string()],
540 }
541 }
542
543 #[test]
544 fn from_naddr() -> Result<()> {
545 assert_eq!(
546 nostr_git_url_to_repo_coordinates(
547 "nostr://naddr1qqzxuemfwsqs6amnwvaz7tmwdaejumr0dspzpgqgmmc409hm4xsdd74sf68a2uyf9pwel4g9mfdg8l5244t6x4jdqvzqqqrhnym0k2qj"
548 )?,
549 HashSet::from([get_model_coordinate()]),
550 );
551 Ok(())
552 }
553 }
554}