diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-09-24 19:22:23 +0100 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-09-24 19:48:14 +0100 |
| commit | 967de64e19c05a2f14e7c97da000c1f3b8ccc4ed (patch) | |
| tree | a675629a7d7731815a79beb3dfefa293e8fa9acc /tests/ngit_push.rs | |
| parent | d01380f7b3efebc9c40a2e71c2ddd635fa936be4 (diff) | |
test: restructure ngit integration tests
so that each file is ran as a seperate crate
this makes it easier to see which tests are causing other tests to
fail as they are in a smaller group.
Diffstat (limited to 'tests/ngit_push.rs')
| -rw-r--r-- | tests/ngit_push.rs | 531 |
1 files changed, 531 insertions, 0 deletions
diff --git a/tests/ngit_push.rs b/tests/ngit_push.rs new file mode 100644 index 0000000..eb452cd --- /dev/null +++ b/tests/ngit_push.rs | |||
| @@ -0,0 +1,531 @@ | |||
| 1 | use anyhow::Result; | ||
| 2 | use futures::join; | ||
| 3 | use serial_test::serial; | ||
| 4 | use test_utils::{git::GitTestRepo, relay::Relay, *}; | ||
| 5 | |||
| 6 | mod when_main_is_checked_out { | ||
| 7 | use super::*; | ||
| 8 | |||
| 9 | #[test] | ||
| 10 | fn cli_returns_error() -> Result<()> { | ||
| 11 | let test_repo = GitTestRepo::default(); | ||
| 12 | test_repo.populate()?; | ||
| 13 | create_and_populate_branch(&test_repo, FEATURE_BRANCH_NAME_1, "a", false)?; | ||
| 14 | test_repo.checkout("main")?; | ||
| 15 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["push"]); | ||
| 16 | p.expect("Error: checkout a branch associated with a proposal first\r\n")?; | ||
| 17 | p.expect_end()?; | ||
| 18 | Ok(()) | ||
| 19 | } | ||
| 20 | } | ||
| 21 | |||
| 22 | mod when_proposal_isnt_associated_with_branch_name { | ||
| 23 | use super::*; | ||
| 24 | |||
| 25 | mod cli_prompts { | ||
| 26 | |||
| 27 | use super::*; | ||
| 28 | |||
| 29 | #[tokio::test] | ||
| 30 | #[serial] | ||
| 31 | async fn cli_show_error() -> Result<()> { | ||
| 32 | let (mut r51, mut r52, mut r53, mut r55, mut r56) = ( | ||
| 33 | Relay::new(8051, None, None), | ||
| 34 | Relay::new(8052, None, None), | ||
| 35 | Relay::new(8053, None, None), | ||
| 36 | Relay::new(8055, None, None), | ||
| 37 | Relay::new(8056, None, None), | ||
| 38 | ); | ||
| 39 | |||
| 40 | r51.events.push(generate_test_key_1_relay_list_event()); | ||
| 41 | r51.events.push(generate_test_key_1_metadata_event("fred")); | ||
| 42 | r51.events.push(generate_repo_ref_event()); | ||
| 43 | |||
| 44 | r55.events.push(generate_repo_ref_event()); | ||
| 45 | r55.events.push(generate_test_key_1_metadata_event("fred")); | ||
| 46 | r55.events.push(generate_test_key_1_relay_list_event()); | ||
| 47 | |||
| 48 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { | ||
| 49 | cli_tester_create_proposals()?; | ||
| 50 | |||
| 51 | let test_repo = GitTestRepo::default(); | ||
| 52 | test_repo.populate()?; | ||
| 53 | |||
| 54 | test_repo.create_branch("random-name")?; | ||
| 55 | test_repo.checkout("random-name")?; | ||
| 56 | |||
| 57 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["push"]); | ||
| 58 | p.expect("fetching updates...\r\n")?; | ||
| 59 | p.expect_eventually("\r\n")?; // some updates listed here | ||
| 60 | p.expect_end_with( | ||
| 61 | "Error: cannot find proposal that matches the current branch name\r\n", | ||
| 62 | )?; | ||
| 63 | for p in [51, 52, 53, 55, 56] { | ||
| 64 | relay::shutdown_relay(8000 + p)?; | ||
| 65 | } | ||
| 66 | Ok(()) | ||
| 67 | }); | ||
| 68 | |||
| 69 | // launch relay | ||
| 70 | let _ = join!( | ||
| 71 | r51.listen_until_close(), | ||
| 72 | r52.listen_until_close(), | ||
| 73 | r53.listen_until_close(), | ||
| 74 | r55.listen_until_close(), | ||
| 75 | r56.listen_until_close(), | ||
| 76 | ); | ||
| 77 | cli_tester_handle.join().unwrap()?; | ||
| 78 | Ok(()) | ||
| 79 | } | ||
| 80 | } | ||
| 81 | } | ||
| 82 | |||
| 83 | mod when_branch_is_checked_out { | ||
| 84 | use super::*; | ||
| 85 | |||
| 86 | mod when_branch_is_up_to_date { | ||
| 87 | use super::*; | ||
| 88 | |||
| 89 | mod cli_prompts { | ||
| 90 | use super::*; | ||
| 91 | #[tokio::test] | ||
| 92 | #[serial] | ||
| 93 | async fn cli_show_up_to_date() -> Result<()> { | ||
| 94 | let (mut r51, mut r52, mut r53, mut r55, mut r56) = ( | ||
| 95 | Relay::new(8051, None, None), | ||
| 96 | Relay::new(8052, None, None), | ||
| 97 | Relay::new(8053, None, None), | ||
| 98 | Relay::new(8055, None, None), | ||
| 99 | Relay::new(8056, None, None), | ||
| 100 | ); | ||
| 101 | |||
| 102 | r51.events.push(generate_test_key_1_relay_list_event()); | ||
| 103 | r51.events.push(generate_test_key_1_metadata_event("fred")); | ||
| 104 | r51.events.push(generate_repo_ref_event()); | ||
| 105 | |||
| 106 | r55.events.push(generate_repo_ref_event()); | ||
| 107 | r55.events.push(generate_test_key_1_metadata_event("fred")); | ||
| 108 | r55.events.push(generate_test_key_1_relay_list_event()); | ||
| 109 | |||
| 110 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { | ||
| 111 | let (_, test_repo) = | ||
| 112 | create_proposals_and_repo_with_proposal_pulled_and_checkedout(1)?; | ||
| 113 | |||
| 114 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["push"]); | ||
| 115 | p.expect("fetching updates...\r\n")?; | ||
| 116 | p.expect_eventually("\r\n")?; // some updates listed here | ||
| 117 | p.expect_end_with("Error: proposal already up-to-date with local branch\r\n")?; | ||
| 118 | |||
| 119 | for p in [51, 52, 53, 55, 56] { | ||
| 120 | relay::shutdown_relay(8000 + p)?; | ||
| 121 | } | ||
| 122 | Ok(()) | ||
| 123 | }); | ||
| 124 | |||
| 125 | // launch relay | ||
| 126 | let _ = join!( | ||
| 127 | r51.listen_until_close(), | ||
| 128 | r52.listen_until_close(), | ||
| 129 | r53.listen_until_close(), | ||
| 130 | r55.listen_until_close(), | ||
| 131 | r56.listen_until_close(), | ||
| 132 | ); | ||
| 133 | cli_tester_handle.join().unwrap()?; | ||
| 134 | Ok(()) | ||
| 135 | } | ||
| 136 | } | ||
| 137 | } | ||
| 138 | |||
| 139 | mod when_branch_is_behind { | ||
| 140 | use super::*; | ||
| 141 | |||
| 142 | mod cli_prompts { | ||
| 143 | use super::*; | ||
| 144 | |||
| 145 | #[tokio::test] | ||
| 146 | #[serial] | ||
| 147 | async fn cli_show_proposal_ahead_error() -> Result<()> { | ||
| 148 | let (mut r51, mut r52, mut r53, mut r55, mut r56) = ( | ||
| 149 | Relay::new(8051, None, None), | ||
| 150 | Relay::new(8052, None, None), | ||
| 151 | Relay::new(8053, None, None), | ||
| 152 | Relay::new(8055, None, None), | ||
| 153 | Relay::new(8056, None, None), | ||
| 154 | ); | ||
| 155 | |||
| 156 | r51.events.push(generate_test_key_1_relay_list_event()); | ||
| 157 | r51.events.push(generate_test_key_1_metadata_event("fred")); | ||
| 158 | r51.events.push(generate_repo_ref_event()); | ||
| 159 | |||
| 160 | r55.events.push(generate_repo_ref_event()); | ||
| 161 | r55.events.push(generate_test_key_1_metadata_event("fred")); | ||
| 162 | r55.events.push(generate_test_key_1_relay_list_event()); | ||
| 163 | |||
| 164 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { | ||
| 165 | let (_, test_repo) = | ||
| 166 | create_proposals_and_repo_with_proposal_pulled_and_checkedout(1)?; | ||
| 167 | |||
| 168 | let branch_name = | ||
| 169 | remove_latest_commit_so_proposal_branch_is_behind_and_checkout_main( | ||
| 170 | &test_repo, | ||
| 171 | )?; | ||
| 172 | |||
| 173 | test_repo.checkout(&branch_name)?; | ||
| 174 | // run test | ||
| 175 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["push"]); | ||
| 176 | p.expect("fetching updates...\r\n")?; | ||
| 177 | p.expect_eventually("\r\n")?; // some updates listed here | ||
| 178 | p.expect("Error: proposal is ahead of local branch\r\n")?; | ||
| 179 | p.expect_end()?; | ||
| 180 | |||
| 181 | for p in [51, 52, 53, 55, 56] { | ||
| 182 | relay::shutdown_relay(8000 + p)?; | ||
| 183 | } | ||
| 184 | Ok(()) | ||
| 185 | }); | ||
| 186 | |||
| 187 | // launch relay | ||
| 188 | let _ = join!( | ||
| 189 | r51.listen_until_close(), | ||
| 190 | r52.listen_until_close(), | ||
| 191 | r53.listen_until_close(), | ||
| 192 | r55.listen_until_close(), | ||
| 193 | r56.listen_until_close(), | ||
| 194 | ); | ||
| 195 | cli_tester_handle.join().unwrap()?; | ||
| 196 | Ok(()) | ||
| 197 | } | ||
| 198 | } | ||
| 199 | } | ||
| 200 | |||
| 201 | mod when_branch_is_ahead { | ||
| 202 | use super::*; | ||
| 203 | |||
| 204 | mod cli_prompts { | ||
| 205 | use test_utils::relay::expect_send_with_progress; | ||
| 206 | |||
| 207 | use super::*; | ||
| 208 | |||
| 209 | #[tokio::test] | ||
| 210 | #[serial] | ||
| 211 | async fn cli_applied_1_commit() -> Result<()> { | ||
| 212 | // fallback (51,52) user write (53, 55) repo (55, 56) | ||
| 213 | let (mut r51, mut r52, mut r53, mut r55, mut r56) = ( | ||
| 214 | Relay::new(8051, None, None), | ||
| 215 | Relay::new(8052, None, None), | ||
| 216 | Relay::new(8053, None, None), | ||
| 217 | Relay::new(8055, None, None), | ||
| 218 | Relay::new(8056, None, None), | ||
| 219 | ); | ||
| 220 | |||
| 221 | r51.events.push(generate_test_key_1_relay_list_event()); | ||
| 222 | r51.events.push(generate_test_key_1_metadata_event("fred")); | ||
| 223 | r51.events.push(generate_repo_ref_event()); | ||
| 224 | |||
| 225 | r55.events.push(generate_repo_ref_event()); | ||
| 226 | r55.events.push(generate_test_key_1_metadata_event("fred")); | ||
| 227 | r55.events.push(generate_test_key_1_relay_list_event()); | ||
| 228 | |||
| 229 | let cli_tester_handle = | ||
| 230 | std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> { | ||
| 231 | let (originating_repo, test_repo) = | ||
| 232 | create_proposals_and_repo_with_proposal_pulled_and_checkedout(1)?; | ||
| 233 | |||
| 234 | // add another commit (so we have an ammened local branch) | ||
| 235 | std::fs::write(test_repo.dir.join("ammended-commit.md"), "some content")?; | ||
| 236 | test_repo.stage_and_commit("add ammended-commit.md")?; | ||
| 237 | |||
| 238 | // run test | ||
| 239 | let mut p = CliTester::new_from_dir( | ||
| 240 | &test_repo.dir, | ||
| 241 | [ | ||
| 242 | "--nsec", | ||
| 243 | TEST_KEY_1_NSEC, | ||
| 244 | "--password", | ||
| 245 | TEST_PASSWORD, | ||
| 246 | "--disable-cli-spinners", | ||
| 247 | "push", | ||
| 248 | ], | ||
| 249 | ); | ||
| 250 | p.expect("fetching updates...\r\n")?; | ||
| 251 | p.expect_eventually("\r\n")?; // some updates listed here | ||
| 252 | p.expect( | ||
| 253 | "1 commits ahead. preparing to create creating patch events.\r\n", | ||
| 254 | )?; | ||
| 255 | p.expect("logged in as fred\r\n")?; | ||
| 256 | p.expect("pushing 1 commits\r\n")?; | ||
| 257 | |||
| 258 | expect_send_with_progress( | ||
| 259 | &mut p, | ||
| 260 | vec![ | ||
| 261 | (" [my-relay] [repo-relay] ws://localhost:8055", true, ""), | ||
| 262 | (" [my-relay] ws://localhost:8053", true, ""), | ||
| 263 | (" [repo-relay] ws://localhost:8056", true, ""), | ||
| 264 | (" [default] ws://localhost:8051", true, ""), | ||
| 265 | (" [default] ws://localhost:8052", true, ""), | ||
| 266 | ], | ||
| 267 | 1, | ||
| 268 | )?; | ||
| 269 | p.expect_eventually("pushed 1 commits\r\n")?; | ||
| 270 | p.expect_end()?; | ||
| 271 | |||
| 272 | for p in [51, 52, 53, 55, 56] { | ||
| 273 | relay::shutdown_relay(8000 + p)?; | ||
| 274 | } | ||
| 275 | Ok((originating_repo, test_repo)) | ||
| 276 | }); | ||
| 277 | |||
| 278 | // launch relay | ||
| 279 | let _ = join!( | ||
| 280 | r51.listen_until_close(), | ||
| 281 | r52.listen_until_close(), | ||
| 282 | r53.listen_until_close(), | ||
| 283 | r55.listen_until_close(), | ||
| 284 | r56.listen_until_close(), | ||
| 285 | ); | ||
| 286 | cli_tester_handle.join().unwrap()?; | ||
| 287 | |||
| 288 | Ok(()) | ||
| 289 | } | ||
| 290 | } | ||
| 291 | |||
| 292 | async fn prep_and_run() -> Result<(GitTestRepo, Vec<nostr::Event>)> { | ||
| 293 | // fallback (51,52) user write (53, 55) repo (55, 56) | ||
| 294 | let (mut r51, mut r52, mut r53, mut r55, mut r56) = ( | ||
| 295 | Relay::new(8051, None, None), | ||
| 296 | Relay::new(8052, None, None), | ||
| 297 | Relay::new(8053, None, None), | ||
| 298 | Relay::new(8055, None, None), | ||
| 299 | Relay::new(8056, None, None), | ||
| 300 | ); | ||
| 301 | |||
| 302 | r51.events.push(generate_test_key_1_relay_list_event()); | ||
| 303 | r51.events.push(generate_test_key_1_metadata_event("fred")); | ||
| 304 | r51.events.push(generate_repo_ref_event()); | ||
| 305 | |||
| 306 | r55.events.push(generate_repo_ref_event()); | ||
| 307 | r55.events.push(generate_test_key_1_metadata_event("fred")); | ||
| 308 | r55.events.push(generate_test_key_1_relay_list_event()); | ||
| 309 | |||
| 310 | let cli_tester_handle = std::thread::spawn(move || -> Result<GitTestRepo> { | ||
| 311 | let (_, test_repo) = | ||
| 312 | create_proposals_and_repo_with_proposal_pulled_and_checkedout(1)?; | ||
| 313 | |||
| 314 | // add another commit (so we have an ammened local branch) | ||
| 315 | std::fs::write(test_repo.dir.join("ammended-commit.md"), "some content")?; | ||
| 316 | test_repo.stage_and_commit("add ammended-commit.md")?; | ||
| 317 | |||
| 318 | // run test | ||
| 319 | |||
| 320 | let mut p = CliTester::new_from_dir( | ||
| 321 | &test_repo.dir, | ||
| 322 | [ | ||
| 323 | "--nsec", | ||
| 324 | TEST_KEY_1_NSEC, | ||
| 325 | "--password", | ||
| 326 | TEST_PASSWORD, | ||
| 327 | "--disable-cli-spinners", | ||
| 328 | "push", | ||
| 329 | ], | ||
| 330 | ); | ||
| 331 | p.expect_end_eventually()?; | ||
| 332 | |||
| 333 | for p in [51, 52, 53, 55, 56] { | ||
| 334 | relay::shutdown_relay(8000 + p)?; | ||
| 335 | } | ||
| 336 | Ok(test_repo) | ||
| 337 | }); | ||
| 338 | |||
| 339 | // launch relay | ||
| 340 | let _ = join!( | ||
| 341 | r51.listen_until_close(), | ||
| 342 | r52.listen_until_close(), | ||
| 343 | r53.listen_until_close(), | ||
| 344 | r55.listen_until_close(), | ||
| 345 | r56.listen_until_close(), | ||
| 346 | ); | ||
| 347 | let res = cli_tester_handle.join().unwrap()?; | ||
| 348 | |||
| 349 | Ok((res, r55.events.clone())) | ||
| 350 | } | ||
| 351 | #[tokio::test] | ||
| 352 | #[serial] | ||
| 353 | async fn commits_issued_as_patch_event() -> Result<()> { | ||
| 354 | let (test_repo, r55_events) = prep_and_run().await?; | ||
| 355 | |||
| 356 | let commit_id = test_repo | ||
| 357 | .get_tip_of_local_branch(&test_repo.get_checked_out_branch_name()?)? | ||
| 358 | .to_string(); | ||
| 359 | assert!(r55_events.iter().any(|e| { | ||
| 360 | e.tags | ||
| 361 | .iter() | ||
| 362 | .any(|t| t.as_vec()[0].eq("commit") && t.as_vec()[1].eq(&commit_id)) | ||
| 363 | })); | ||
| 364 | Ok(()) | ||
| 365 | } | ||
| 366 | } | ||
| 367 | |||
| 368 | mod when_branch_has_been_rebased { | ||
| 369 | use super::*; | ||
| 370 | |||
| 371 | mod cli_prompts { | ||
| 372 | use super::*; | ||
| 373 | |||
| 374 | #[tokio::test] | ||
| 375 | #[serial] | ||
| 376 | async fn cli_shows_unpublished_rebase_error() -> Result<()> { | ||
| 377 | let (mut r51, mut r52, mut r53, mut r55, mut r56) = ( | ||
| 378 | Relay::new(8051, None, None), | ||
| 379 | Relay::new(8052, None, None), | ||
| 380 | Relay::new(8053, None, None), | ||
| 381 | Relay::new(8055, None, None), | ||
| 382 | Relay::new(8056, None, None), | ||
| 383 | ); | ||
| 384 | |||
| 385 | r51.events.push(generate_test_key_1_relay_list_event()); | ||
| 386 | r51.events.push(generate_test_key_1_metadata_event("fred")); | ||
| 387 | r51.events.push(generate_repo_ref_event()); | ||
| 388 | |||
| 389 | r55.events.push(generate_repo_ref_event()); | ||
| 390 | r55.events.push(generate_test_key_1_metadata_event("fred")); | ||
| 391 | r55.events.push(generate_test_key_1_relay_list_event()); | ||
| 392 | |||
| 393 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { | ||
| 394 | let (_, tmp_repo) = | ||
| 395 | create_proposals_and_repo_with_proposal_pulled_and_checkedout(1)?; | ||
| 396 | let branch_name = tmp_repo.get_checked_out_branch_name()?; | ||
| 397 | |||
| 398 | let test_repo = GitTestRepo::default(); | ||
| 399 | test_repo.populate()?; | ||
| 400 | |||
| 401 | // simulate rebase | ||
| 402 | std::fs::write(test_repo.dir.join("amazing.md"), "some content")?; | ||
| 403 | test_repo.stage_and_commit("commit for rebasing on top of")?; | ||
| 404 | create_and_populate_branch(&test_repo, &branch_name, "a", true)?; | ||
| 405 | |||
| 406 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["push"]); | ||
| 407 | // p.expect_end_eventually_and_print()?; | ||
| 408 | |||
| 409 | p.expect("fetching updates...\r\n")?; | ||
| 410 | p.expect_eventually("\r\n")?; // some updates listed here | ||
| 411 | p.expect( | ||
| 412 | "Error: local unpublished proposal has been rebased. consider force pushing\r\n", | ||
| 413 | )?; | ||
| 414 | p.expect_end()?; | ||
| 415 | |||
| 416 | for p in [51, 52, 53, 55, 56] { | ||
| 417 | relay::shutdown_relay(8000 + p)?; | ||
| 418 | } | ||
| 419 | Ok(()) | ||
| 420 | }); | ||
| 421 | |||
| 422 | // launch relay | ||
| 423 | let _ = join!( | ||
| 424 | r51.listen_until_close(), | ||
| 425 | r52.listen_until_close(), | ||
| 426 | r53.listen_until_close(), | ||
| 427 | r55.listen_until_close(), | ||
| 428 | r56.listen_until_close(), | ||
| 429 | ); | ||
| 430 | cli_tester_handle.join().unwrap()?; | ||
| 431 | Ok(()) | ||
| 432 | } | ||
| 433 | } | ||
| 434 | mod with_force_flag { | ||
| 435 | use super::*; | ||
| 436 | |||
| 437 | mod cli_prompts { | ||
| 438 | use super::*; | ||
| 439 | |||
| 440 | #[tokio::test] | ||
| 441 | #[serial] | ||
| 442 | async fn cli_shows_revision_sent() -> Result<()> { | ||
| 443 | let (mut r51, mut r52, mut r53, mut r55, mut r56) = ( | ||
| 444 | Relay::new(8051, None, None), | ||
| 445 | Relay::new(8052, None, None), | ||
| 446 | Relay::new(8053, None, None), | ||
| 447 | Relay::new(8055, None, None), | ||
| 448 | Relay::new(8056, None, None), | ||
| 449 | ); | ||
| 450 | |||
| 451 | r51.events.push(generate_test_key_1_relay_list_event()); | ||
| 452 | r51.events.push(generate_test_key_1_metadata_event("fred")); | ||
| 453 | r51.events.push(generate_repo_ref_event()); | ||
| 454 | |||
| 455 | r55.events.push(generate_repo_ref_event()); | ||
| 456 | r55.events.push(generate_test_key_1_metadata_event("fred")); | ||
| 457 | r55.events.push(generate_test_key_1_relay_list_event()); | ||
| 458 | |||
| 459 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { | ||
| 460 | let (_, tmp_repo) = | ||
| 461 | create_proposals_and_repo_with_proposal_pulled_and_checkedout(1)?; | ||
| 462 | let branch_name = tmp_repo.get_checked_out_branch_name()?; | ||
| 463 | |||
| 464 | let test_repo = GitTestRepo::default(); | ||
| 465 | test_repo.populate()?; | ||
| 466 | |||
| 467 | // simulate rebase | ||
| 468 | std::fs::write(test_repo.dir.join("amazing.md"), "some content")?; | ||
| 469 | test_repo.stage_and_commit("commit for rebasing on top of")?; | ||
| 470 | create_and_populate_branch(&test_repo, &branch_name, "a", false)?; | ||
| 471 | let mut p = CliTester::new_from_dir( | ||
| 472 | &test_repo.dir, | ||
| 473 | [ | ||
| 474 | "--nsec", | ||
| 475 | TEST_KEY_1_NSEC, | ||
| 476 | "--password", | ||
| 477 | TEST_PASSWORD, | ||
| 478 | "--disable-cli-spinners", | ||
| 479 | "push", | ||
| 480 | "--force", | ||
| 481 | ], | ||
| 482 | ); | ||
| 483 | p.expect("fetching updates...\r\n")?; | ||
| 484 | p.expect_eventually("\r\n")?; // some updates listed here | ||
| 485 | p.expect("preparing to force push proposal revision...\r\n")?; | ||
| 486 | // standard output from `ngit send` | ||
| 487 | p.expect("creating proposal revision for: ")?; | ||
| 488 | // proposal id will be printed in this gap | ||
| 489 | p.expect_eventually("\r\n")?; | ||
| 490 | p.expect("creating proposal from 2 commits:\r\n")?; | ||
| 491 | p.expect("355bdf1 add a4.md\r\n")?; | ||
| 492 | p.expect("dbd1115 add a3.md\r\n")?; | ||
| 493 | p.expect("logged in as fred\r\n")?; | ||
| 494 | p.expect("posting 2 patches without a covering letter...\r\n")?; | ||
| 495 | |||
| 496 | relay::expect_send_with_progress( | ||
| 497 | &mut p, | ||
| 498 | vec![ | ||
| 499 | (" [my-relay] [repo-relay] ws://localhost:8055", true, ""), | ||
| 500 | (" [my-relay] ws://localhost:8053", true, ""), | ||
| 501 | (" [repo-relay] ws://localhost:8056", true, ""), | ||
| 502 | (" [default] ws://localhost:8051", true, ""), | ||
| 503 | (" [default] ws://localhost:8052", true, ""), | ||
| 504 | ], | ||
| 505 | 2, | ||
| 506 | )?; | ||
| 507 | // end standard `ngit send output` | ||
| 508 | p.expect_after_whitespace("force pushed proposal revision\r\n")?; | ||
| 509 | p.expect_end()?; | ||
| 510 | |||
| 511 | for p in [51, 52, 53, 55, 56] { | ||
| 512 | relay::shutdown_relay(8000 + p)?; | ||
| 513 | } | ||
| 514 | Ok(()) | ||
| 515 | }); | ||
| 516 | |||
| 517 | // launch relay | ||
| 518 | let _ = join!( | ||
| 519 | r51.listen_until_close(), | ||
| 520 | r52.listen_until_close(), | ||
| 521 | r53.listen_until_close(), | ||
| 522 | r55.listen_until_close(), | ||
| 523 | r56.listen_until_close(), | ||
| 524 | ); | ||
| 525 | cli_tester_handle.join().unwrap()?; | ||
| 526 | Ok(()) | ||
| 527 | } | ||
| 528 | } | ||
| 529 | } | ||
| 530 | } | ||
| 531 | } | ||