upleb.uk

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

summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2024-08-05 12:17:37 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2024-08-05 12:17:37 +0100
commite5750b5b3dfe2c0072902c2523fdf32986aa74b8 (patch)
tree753706d0fb350dcc455921a0ab46e0a82717afc2 /tests
parent36b336716048058a8c37731b3f0968b4dc37a071 (diff)
test(remote): remove `async_run_test`
where it is not needed so code is easier to read
Diffstat (limited to 'tests')
-rw-r--r--tests/git_remote_helper.rs64
1 files changed, 21 insertions, 43 deletions
diff --git a/tests/git_remote_helper.rs b/tests/git_remote_helper.rs
index 0b600f6..5a6c5f5 100644
--- a/tests/git_remote_helper.rs
+++ b/tests/git_remote_helper.rs
@@ -145,7 +145,10 @@ async fn generate_repo_with_state_event() -> Result<(nostr::Event, GitTestRepo)>
145mod initially_runs_fetch { 145mod initially_runs_fetch {
146 146
147 use super::*; 147 use super::*;
148 async fn async_run_test() -> Result<()> { 148
149 #[tokio::test]
150 #[serial]
151 async fn runs_fetch_and_reports() -> Result<()> {
149 let source_git_repo = prep_git_repo()?; 152 let source_git_repo = prep_git_repo()?;
150 let git_repo = prep_git_repo()?; 153 let git_repo = prep_git_repo()?;
151 let events = vec![ 154 let events = vec![
@@ -189,12 +192,6 @@ mod initially_runs_fetch {
189 cli_tester_handle.join().unwrap()?; 192 cli_tester_handle.join().unwrap()?;
190 Ok(()) 193 Ok(())
191 } 194 }
192
193 #[tokio::test]
194 #[serial]
195 async fn runs_fetch_and_reports() -> Result<()> {
196 async_run_test().await
197 }
198} 195}
199 196
200mod list { 197mod list {
@@ -205,7 +202,9 @@ mod list {
205 202
206 use super::*; 203 use super::*;
207 204
208 async fn async_run_test() -> Result<()> { 205 #[tokio::test]
206 #[serial]
207 async fn lists_head_and_2_branches_and_commit_ids_from_git_server() -> Result<()> {
209 let source_git_repo = prep_git_repo()?; 208 let source_git_repo = prep_git_repo()?;
210 let source_path = source_git_repo.dir.to_str().unwrap().to_string(); 209 let source_path = source_git_repo.dir.to_str().unwrap().to_string();
211 std::fs::write(source_git_repo.dir.join("commit.md"), "some content")?; 210 std::fs::write(source_git_repo.dir.join("commit.md"), "some content")?;
@@ -271,12 +270,6 @@ mod list {
271 cli_tester_handle.join().unwrap()?; 270 cli_tester_handle.join().unwrap()?;
272 Ok(()) 271 Ok(())
273 } 272 }
274
275 #[tokio::test]
276 #[serial]
277 async fn lists_head_and_2_branches_and_commit_ids_from_git_server() -> Result<()> {
278 async_run_test().await
279 }
280 } 273 }
281 mod with_state_announcement { 274 mod with_state_announcement {
282 275
@@ -286,7 +279,9 @@ mod list {
286 279
287 use super::*; 280 use super::*;
288 281
289 async fn async_run_test() -> Result<()> { 282 #[tokio::test]
283 #[serial]
284 async fn lists_head_and_2_branches_and_commit_ids_announcement() -> Result<()> {
290 let (state_event, source_git_repo) = generate_repo_with_state_event().await?; 285 let (state_event, source_git_repo) = generate_repo_with_state_event().await?;
291 let source_path = source_git_repo.dir.to_str().unwrap().to_string(); 286 let source_path = source_git_repo.dir.to_str().unwrap().to_string();
292 287
@@ -350,18 +345,14 @@ mod list {
350 cli_tester_handle.join().unwrap()?; 345 cli_tester_handle.join().unwrap()?;
351 Ok(()) 346 Ok(())
352 } 347 }
353
354 #[tokio::test]
355 #[serial]
356 async fn lists_head_and_2_branches_and_commit_ids_announcement() -> Result<()> {
357 async_run_test().await
358 }
359 } 348 }
360 mod when_announcement_doesnt_match_git_server { 349 mod when_announcement_doesnt_match_git_server {
361 350
362 use super::*; 351 use super::*;
363 352
364 async fn async_run_test() -> Result<()> { 353 #[tokio::test]
354 #[serial]
355 async fn anouncement_state_is_used() -> Result<()> {
365 let (state_event, source_git_repo) = generate_repo_with_state_event().await?; 356 let (state_event, source_git_repo) = generate_repo_with_state_event().await?;
366 let source_path = source_git_repo.dir.to_str().unwrap().to_string(); 357 let source_path = source_git_repo.dir.to_str().unwrap().to_string();
367 let main_original_commit_id = source_git_repo.get_tip_of_local_branch("main")?; 358 let main_original_commit_id = source_git_repo.get_tip_of_local_branch("main")?;
@@ -443,12 +434,6 @@ mod list {
443 cli_tester_handle.join().unwrap()?; 434 cli_tester_handle.join().unwrap()?;
444 Ok(()) 435 Ok(())
445 } 436 }
446
447 #[tokio::test]
448 #[serial]
449 async fn anouncement_state_is_used() -> Result<()> {
450 async_run_test().await
451 }
452 } 437 }
453 } 438 }
454} 439}
@@ -457,7 +442,9 @@ mod fetch {
457 442
458 use super::*; 443 use super::*;
459 444
460 async fn async_run_test() -> Result<()> { 445 #[tokio::test]
446 #[serial]
447 async fn fetch_downloads_speficied_commits_from_git_server() -> Result<()> {
461 let source_git_repo = prep_git_repo()?; 448 let source_git_repo = prep_git_repo()?;
462 std::fs::write(source_git_repo.dir.join("commit.md"), "some content")?; 449 std::fs::write(source_git_repo.dir.join("commit.md"), "some content")?;
463 let main_commit_id = source_git_repo.stage_and_commit("commit.md")?; 450 let main_commit_id = source_git_repo.stage_and_commit("commit.md")?;
@@ -519,15 +506,12 @@ mod fetch {
519 Ok(()) 506 Ok(())
520 } 507 }
521 508
522 #[tokio::test]
523 #[serial]
524 async fn fetch_downloads_speficied_commits_from_git_server() -> Result<()> {
525 async_run_test().await
526 }
527
528 mod when_first_git_server_fails_ { 509 mod when_first_git_server_fails_ {
529 use super::*; 510 use super::*;
530 async fn async_run_test() -> Result<()> { 511
512 #[tokio::test]
513 #[serial]
514 async fn fetch_downloads_speficied_commits_from_second_git_server() -> Result<()> {
531 let (state_event, source_git_repo) = generate_repo_with_state_event().await?; 515 let (state_event, source_git_repo) = generate_repo_with_state_event().await?;
532 516
533 let main_commit_id = source_git_repo.get_tip_of_local_branch("main")?; 517 let main_commit_id = source_git_repo.get_tip_of_local_branch("main")?;
@@ -583,12 +567,6 @@ mod fetch {
583 cli_tester_handle.join().unwrap()?; 567 cli_tester_handle.join().unwrap()?;
584 Ok(()) 568 Ok(())
585 } 569 }
586
587 #[tokio::test]
588 #[serial]
589 async fn fetch_downloads_speficied_commits_from_second_git_server() -> Result<()> {
590 async_run_test().await
591 }
592 } 570 }
593} 571}
594 572
@@ -970,7 +948,7 @@ mod push {
970 p.send_line("push refs/heads/main:refs/heads/main")?; 948 p.send_line("push refs/heads/main:refs/heads/main")?;
971 p.send_line("push refs/heads/vnext:refs/heads/vnext")?; 949 p.send_line("push refs/heads/vnext:refs/heads/vnext")?;
972 p.send_line("")?; 950 p.send_line("")?;
973 p.expect_eventually("\r\n\r\n")?; 951 p.expect_eventually_and_print("\r\n\r\n")?;
974 p.exit()?; 952 p.exit()?;
975 for p in [51, 52, 53, 55, 56, 57] { 953 for p in [51, 52, 53, 55, 56, 57] {
976 relay::shutdown_relay(8000 + p)?; 954 relay::shutdown_relay(8000 + p)?;