Skip to content

Commit 2e87a82

Browse files
committed
Add test for running the merge queue with the queue being empty
1 parent 3eb84da commit 2e87a82

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

src/bors/merge_queue.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,12 @@ async fn process_repository(repo: &RepositoryState, ctx: &BorsContext) -> anyhow
134134
let pr_num = pr.number;
135135

136136
match pr.queue_status() {
137-
QueueStatus::NotApproved => unreachable!(),
138-
QueueStatus::Stalled(..) => unreachable!(),
137+
QueueStatus::NotApproved => unreachable!(
138+
"PR {pr:?} is not approved. It should not have been returned by `get_merge_queue_prs`, this is a bug."
139+
),
140+
QueueStatus::Stalled(..) => unreachable!(
141+
"PR {pr:?} is stalled. It should not have been returned by `get_merge_queue_prs`, this is a bug."
142+
),
139143
QueueStatus::Pending(..) => {
140144
// Build in progress - stop queue. We can only have one PR being built
141145
// at a time.
@@ -1115,4 +1119,21 @@ auto_build_failed = ["+foo", "+bar", "-baz"]
11151119
})
11161120
.await;
11171121
}
1122+
1123+
#[sqlx::test]
1124+
async fn run_empty_queue(pool: sqlx::PgPool) {
1125+
run_test(pool, async |tester: &mut BorsTester| {
1126+
// This PR should not be in the queue
1127+
let pr = tester.open_pr(default_repo_name(), |_| {}).await?;
1128+
// Make sure that bors knows about the DB
1129+
tester
1130+
.post_comment(Comment::new(pr.id(), "@bors info"))
1131+
.await?;
1132+
tester.expect_comments(pr.id(), 1).await;
1133+
1134+
tester.process_merge_queue().await;
1135+
Ok(())
1136+
})
1137+
.await;
1138+
}
11181139
}

0 commit comments

Comments
 (0)