Skip to content

Commit 7e61fb1

Browse files
committed
Add tests
1 parent cbe518d commit 7e61fb1

File tree

5 files changed

+346
-153
lines changed

5 files changed

+346
-153
lines changed

src/bors/handlers/workflow.rs

Lines changed: 50 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -467,57 +467,73 @@ mod tests {
467467

468468
#[sqlx::test]
469469
async fn auto_build_success_comment(pool: sqlx::PgPool) {
470-
run_test(pool, |mut tester| async {
471-
tester.create_branch(AUTO_BRANCH_NAME).expect_suites(1);
470+
let github = GitHubState::default().with_default_config(
471+
r#"
472+
merge_queue_enabled = true
473+
"#,
474+
);
472475

473-
tester.post_comment("@bors r+").await?;
474-
tester.expect_comments(1).await;
476+
BorsBuilder::new(pool)
477+
.github(github)
478+
.run_test(|mut tester| async {
479+
tester.create_branch(AUTO_BRANCH_NAME).expect_suites(1);
475480

476-
tester.process_merge_queue().await;
477-
tester.expect_comments(1).await;
481+
tester.post_comment("@bors r+").await?;
482+
tester.expect_comments(1).await;
478483

479-
tester.workflow_success(tester.auto_branch()).await?;
480-
tester.process_merge_queue().await;
481-
insta::assert_snapshot!(
482-
tester.get_comment().await?,
483-
@r"
484+
tester.process_merge_queue().await;
485+
tester.expect_comments(1).await;
486+
487+
tester.workflow_success(tester.auto_branch()).await?;
488+
tester.process_merge_queue().await;
489+
insta::assert_snapshot!(
490+
tester.get_comment().await?,
491+
@r"
484492
:sunny: Test successful - [Workflow1](https://github.com/workflows/Workflow1/1)
485493
Approved by: `default-user`
486494
Pushing merge-main-sha1-pr-1-sha-0 to `main`...
487495
"
488-
);
496+
);
489497

490-
Ok(tester)
491-
})
492-
.await;
498+
Ok(tester)
499+
})
500+
.await;
493501
}
494502

495503
#[sqlx::test]
496504
async fn auto_build_check_run_success(pool: sqlx::PgPool) {
497-
run_test(pool, |mut tester| async {
498-
tester.create_branch(AUTO_BRANCH_NAME).expect_suites(1);
505+
let github = GitHubState::default().with_default_config(
506+
r#"
507+
merge_queue_enabled = true
508+
"#,
509+
);
499510

500-
tester.post_comment("@bors r+").await?;
501-
tester.expect_comments(1).await;
511+
BorsBuilder::new(pool)
512+
.github(github)
513+
.run_test(|mut tester| async {
514+
tester.create_branch(AUTO_BRANCH_NAME).expect_suites(1);
502515

503-
tester.process_merge_queue().await;
504-
tester.expect_comments(1).await;
516+
tester.post_comment("@bors r+").await?;
517+
tester.expect_comments(1).await;
505518

506-
tester.workflow_success(tester.auto_branch()).await?;
507-
tester.process_merge_queue().await;
508-
tester.expect_comments(1).await;
519+
tester.process_merge_queue().await;
520+
tester.expect_comments(1).await;
509521

510-
tester.expect_check_run(
511-
&tester.default_pr().await.get_gh_pr().head_sha,
512-
AUTO_BUILD_CHECK_RUN_NAME,
513-
AUTO_BUILD_CHECK_RUN_NAME,
514-
CheckRunStatus::Completed,
515-
Some(CheckRunConclusion::Success),
516-
);
522+
tester.workflow_success(tester.auto_branch()).await?;
523+
tester.process_merge_queue().await;
524+
tester.expect_comments(1).await;
517525

518-
Ok(tester)
519-
})
520-
.await;
526+
tester.expect_check_run(
527+
&tester.default_pr().await.get_gh_pr().head_sha,
528+
AUTO_BUILD_CHECK_RUN_NAME,
529+
AUTO_BUILD_CHECK_RUN_NAME,
530+
CheckRunStatus::Completed,
531+
Some(CheckRunConclusion::Success),
532+
);
533+
534+
Ok(tester)
535+
})
536+
.await;
521537
}
522538

523539
#[sqlx::test]

0 commit comments

Comments
 (0)