diff options
Diffstat (limited to 'tests/git_remote_helper.rs')
| -rw-r--r-- | tests/git_remote_helper.rs | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/tests/git_remote_helper.rs b/tests/git_remote_helper.rs index b63345c..a9e60ae 100644 --- a/tests/git_remote_helper.rs +++ b/tests/git_remote_helper.rs | |||
| @@ -207,6 +207,7 @@ mod list { | |||
| 207 | 207 | ||
| 208 | async fn async_run_test() -> Result<()> { | 208 | async fn async_run_test() -> Result<()> { |
| 209 | let source_git_repo = prep_git_repo()?; | 209 | let source_git_repo = prep_git_repo()?; |
| 210 | let source_path = source_git_repo.dir.to_str().unwrap().to_string(); | ||
| 210 | std::fs::write(source_git_repo.dir.join("commit.md"), "some content")?; | 211 | std::fs::write(source_git_repo.dir.join("commit.md"), "some content")?; |
| 211 | let main_commit_id = source_git_repo.stage_and_commit("commit.md")?; | 212 | let main_commit_id = source_git_repo.stage_and_commit("commit.md")?; |
| 212 | 213 | ||
| @@ -239,10 +240,15 @@ mod list { | |||
| 239 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { | 240 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { |
| 240 | let mut p = cli_tester_after_fetch(&git_repo)?; | 241 | let mut p = cli_tester_after_fetch(&git_repo)?; |
| 241 | p.send_line("list")?; | 242 | p.send_line("list")?; |
| 243 | p.expect(format!("fetching refs list: {}...\r\n\r", source_path).as_str())?; | ||
| 242 | // println!("{}", p.expect_eventually("\r\n\r\n")?); | 244 | // println!("{}", p.expect_eventually("\r\n\r\n")?); |
| 245 | let res = p.expect_eventually("\r\n\r\n")?; | ||
| 246 | p.exit()?; | ||
| 247 | for p in [51, 52, 53, 55, 56, 57] { | ||
| 248 | relay::shutdown_relay(8000 + p)?; | ||
| 249 | } | ||
| 243 | assert_eq!( | 250 | assert_eq!( |
| 244 | p.expect_eventually("\r\n\r\n")? | 251 | res.split("\r\n") |
| 245 | .split("\r\n") | ||
| 246 | .map(|e| e.to_string()) | 252 | .map(|e| e.to_string()) |
| 247 | .collect::<HashSet<String>>(), | 253 | .collect::<HashSet<String>>(), |
| 248 | HashSet::from([ | 254 | HashSet::from([ |
| @@ -251,10 +257,6 @@ mod list { | |||
| 251 | format!("{} refs/heads/vnext", vnext_commit_id), | 257 | format!("{} refs/heads/vnext", vnext_commit_id), |
| 252 | ]), | 258 | ]), |
| 253 | ); | 259 | ); |
| 254 | p.exit()?; | ||
| 255 | for p in [51, 52, 53, 55, 56, 57] { | ||
| 256 | relay::shutdown_relay(8000 + p)?; | ||
| 257 | } | ||
| 258 | Ok(()) | 260 | Ok(()) |
| 259 | }); | 261 | }); |
| 260 | // launch relays | 262 | // launch relays |
| @@ -286,6 +288,7 @@ mod list { | |||
| 286 | 288 | ||
| 287 | async fn async_run_test() -> Result<()> { | 289 | async fn async_run_test() -> Result<()> { |
| 288 | let (state_event, source_git_repo) = generate_repo_with_state_event().await?; | 290 | 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(); | ||
| 289 | 292 | ||
| 290 | let main_commit_id = source_git_repo.get_tip_of_local_branch("main")?; | 293 | let main_commit_id = source_git_repo.get_tip_of_local_branch("main")?; |
| 291 | let example_commit_id = | 294 | let example_commit_id = |
| @@ -315,10 +318,15 @@ mod list { | |||
| 315 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { | 318 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { |
| 316 | let mut p = cli_tester_after_fetch(&git_repo)?; | 319 | let mut p = cli_tester_after_fetch(&git_repo)?; |
| 317 | p.send_line("list")?; | 320 | p.send_line("list")?; |
| 321 | p.expect(format!("fetching refs list: {}...\r\n\r", source_path).as_str())?; | ||
| 318 | // println!("{}", p.expect_eventually("\r\n\r\n")?); | 322 | // println!("{}", p.expect_eventually("\r\n\r\n")?); |
| 323 | let res = p.expect_eventually("\r\n\r\n")?; | ||
| 324 | p.exit()?; | ||
| 325 | for p in [51, 52, 53, 55, 56, 57] { | ||
| 326 | relay::shutdown_relay(8000 + p)?; | ||
| 327 | } | ||
| 319 | assert_eq!( | 328 | assert_eq!( |
| 320 | p.expect_eventually("\r\n\r\n")? | 329 | res.split("\r\n") |
| 321 | .split("\r\n") | ||
| 322 | .map(|e| e.to_string()) | 330 | .map(|e| e.to_string()) |
| 323 | .collect::<HashSet<String>>(), | 331 | .collect::<HashSet<String>>(), |
| 324 | HashSet::from([ | 332 | HashSet::from([ |
| @@ -327,10 +335,7 @@ mod list { | |||
| 327 | format!("{} refs/heads/example-branch", example_commit_id), | 335 | format!("{} refs/heads/example-branch", example_commit_id), |
| 328 | ]), | 336 | ]), |
| 329 | ); | 337 | ); |
| 330 | p.exit()?; | 338 | |
| 331 | for p in [51, 52, 53, 55, 56, 57] { | ||
| 332 | relay::shutdown_relay(8000 + p)?; | ||
| 333 | } | ||
| 334 | Ok(()) | 339 | Ok(()) |
| 335 | }); | 340 | }); |
| 336 | // launch relays | 341 | // launch relays |
| @@ -358,6 +363,7 @@ mod list { | |||
| 358 | 363 | ||
| 359 | async fn async_run_test() -> Result<()> { | 364 | async fn async_run_test() -> Result<()> { |
| 360 | let (state_event, source_git_repo) = generate_repo_with_state_event().await?; | 365 | 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(); | ||
| 361 | let main_original_commit_id = source_git_repo.get_tip_of_local_branch("main")?; | 367 | let main_original_commit_id = source_git_repo.get_tip_of_local_branch("main")?; |
| 362 | 368 | ||
| 363 | { | 369 | { |
| @@ -398,10 +404,16 @@ mod list { | |||
| 398 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { | 404 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { |
| 399 | let mut p = cli_tester_after_fetch(&git_repo)?; | 405 | let mut p = cli_tester_after_fetch(&git_repo)?; |
| 400 | p.send_line("list")?; | 406 | p.send_line("list")?; |
| 407 | p.expect(format!("fetching refs list: {}...\r\n\r", source_path).as_str())?; | ||
| 408 | |||
| 401 | // println!("{}", p.expect_eventually("\r\n\r\n")?); | 409 | // println!("{}", p.expect_eventually("\r\n\r\n")?); |
| 410 | let res = p.expect_eventually("\r\n\r\n")?; | ||
| 411 | p.exit()?; | ||
| 412 | for p in [51, 52, 53, 55, 56, 57] { | ||
| 413 | relay::shutdown_relay(8000 + p)?; | ||
| 414 | } | ||
| 402 | assert_eq!( | 415 | assert_eq!( |
| 403 | p.expect_eventually("\r\n\r\n")? | 416 | res.split("\r\n") |
| 404 | .split("\r\n") | ||
| 405 | .map(|e| e.to_string()) | 417 | .map(|e| e.to_string()) |
| 406 | .collect::<HashSet<String>>(), | 418 | .collect::<HashSet<String>>(), |
| 407 | HashSet::from([ | 419 | HashSet::from([ |
| @@ -410,10 +422,6 @@ mod list { | |||
| 410 | format!("{} refs/heads/example-branch", example_commit_id), | 422 | format!("{} refs/heads/example-branch", example_commit_id), |
| 411 | ]), | 423 | ]), |
| 412 | ); | 424 | ); |
| 413 | p.exit()?; | ||
| 414 | for p in [51, 52, 53, 55, 56, 57] { | ||
| 415 | relay::shutdown_relay(8000 + p)?; | ||
| 416 | } | ||
| 417 | Ok(()) | 425 | Ok(()) |
| 418 | }); | 426 | }); |
| 419 | // launch relays | 427 | // launch relays |