From 51c9541f8355fef82cab783b502ead9ea0f5cf19 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 29 Nov 2024 10:05:19 +0000 Subject: test(init): remove maintainers.yaml from tests as creation by default was removed in 9bee5f12efa5ed751468c68073c9122e12c22b5f --- tests/ngit_init.rs | 185 ----------------------------------------------------- 1 file changed, 185 deletions(-) diff --git a/tests/ngit_init.rs b/tests/ngit_init.rs index 4302524..7d1fb55 100644 --- a/tests/ngit_init.rs +++ b/tests/ngit_init.rs @@ -11,14 +11,6 @@ fn expect_msgs_first(p: &mut CliTester) -> Result<()> { Ok(()) } -fn expect_msgs_after(p: &mut CliTester) -> Result<()> { - p.expect_after_whitespace("maintainers.yaml created. commit and push.\r\n")?; - p.expect( - "this optional file helps in identifying who the maintainers are over time through the commit history\r\n", - )?; - Ok(()) -} - fn get_cli_args() -> Vec<&'static str> { vec![ "--nsec", @@ -194,182 +186,6 @@ mod when_repo_not_previously_claimed { } } - mod yaml_file { - use std::{fs, io::Read}; - - use super::*; - - async fn async_run_test() -> Result<()> { - let git_repo = prep_git_repo()?; - // fallback (51,52) user write (53, 55) repo (55, 56) blaster (57) - let (mut r51, mut r52, mut r53, mut r55, mut r56, mut r57) = ( - Relay::new( - 8051, - None, - Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events( - client_id, - &subscription_id, - &vec![ - generate_test_key_1_metadata_event("fred"), - generate_test_key_1_relay_list_event(), - ], - )?; - Ok(()) - }), - ), - Relay::new(8052, None, None), - Relay::new(8053, None, None), - Relay::new(8055, None, None), - Relay::new(8056, None, None), - Relay::new(8057, None, None), - ); - - // // check relay had the right number of events - let cli_tester_handle = std::thread::spawn(move || -> Result<()> { - let mut p = cli_tester_init(&git_repo); - p.expect_end_eventually()?; - - let yaml_path = git_repo.dir.join("maintainers.yaml"); - - assert!(yaml_path.exists()); - - let mut file = fs::File::open(yaml_path).expect("no such file"); - let mut file_contents = "".to_string(); - let _ = file.read_to_string(&mut file_contents); - - for p in [51, 52, 53, 55, 56, 57] { - relay::shutdown_relay(8000 + p)?; - } - assert_eq!( - file_contents, - format!( - "\ - identifier: example-identifier\n\ - maintainers:\n\ - - {TEST_KEY_1_NPUB}\n\ - relays:\n\ - - ws://localhost:8055\n\ - - ws://localhost:8056\n\ - " - ), - ); - Ok(()) - }); - - // launch relay - let _ = join!( - r51.listen_until_close(), - r52.listen_until_close(), - r53.listen_until_close(), - r55.listen_until_close(), - r56.listen_until_close(), - r57.listen_until_close(), - ); - cli_tester_handle.join().unwrap()?; - Ok(()) - } - - #[tokio::test] - #[serial] - async fn contains_identifier_maintainers_and_relays() -> Result<()> { - async_run_test().await - } - mod updates_existing_with_missing_identifier { - use std::io::Write; - - use super::*; - async fn async_run_test() -> Result<()> { - let git_repo = prep_git_repo()?; - // fallback (51,52) user write (53, 55) repo (55, 56) blaster (57) - let (mut r51, mut r52, mut r53, mut r55, mut r56, mut r57) = ( - Relay::new( - 8051, - None, - Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events( - client_id, - &subscription_id, - &vec![ - generate_test_key_1_metadata_event("fred"), - generate_test_key_1_relay_list_event(), - ], - )?; - Ok(()) - }), - ), - Relay::new(8052, None, None), - Relay::new(8053, None, None), - Relay::new(8055, None, None), - Relay::new(8056, None, None), - Relay::new(8057, None, None), - ); - - // // check relay had the right number of events - let cli_tester_handle = std::thread::spawn(move || -> Result<()> { - let yaml_path = git_repo.dir.join("maintainers.yaml"); - let mut file = std::fs::File::create(&yaml_path) - .expect("failed to create maintainers.yaml file"); - write!( - file, - "\ - maintainers:\n\ - - {TEST_KEY_1_NPUB}\n\ - relays:\n\ - - ws://localhost:8055\n\ - - ws://localhost:8056\n\ - " - )?; - - let mut p = cli_tester_init(&git_repo); - p.expect_end_eventually()?; - - assert!(yaml_path.exists()); - - let mut file = fs::File::open(yaml_path).expect("no such file"); - let mut file_contents = "".to_string(); - let _ = file.read_to_string(&mut file_contents); - - for p in [51, 52, 53, 55, 56, 57] { - relay::shutdown_relay(8000 + p)?; - } - assert_eq!( - file_contents, - format!( - "\ - identifier: example-identifier\n\ - maintainers:\n\ - - {TEST_KEY_1_NPUB}\n\ - relays:\n\ - - ws://localhost:8055\n\ - - ws://localhost:8056\n\ - " - ), - ); - Ok(()) - }); - - // launch relay - let _ = join!( - r51.listen_until_close(), - r52.listen_until_close(), - r53.listen_until_close(), - r55.listen_until_close(), - r56.listen_until_close(), - r57.listen_until_close(), - ); - cli_tester_handle.join().unwrap()?; - Ok(()) - } - - #[tokio::test] - #[serial] - async fn adds_missing_identifier() -> Result<()> { - async_run_test().await - } - } - } - mod git_config_updated { use nostr::nips::nip01::Coordinate; @@ -678,7 +494,6 @@ mod when_repo_not_previously_claimed { ], 1, )?; - expect_msgs_after(&mut p)?; p.expect_end()?; for p in [51, 52, 53, 55, 56, 57] { relay::shutdown_relay(8000 + p)?; -- cgit v1.2.3