Skip to content

Commit 2ab8f3a

Browse files
authored
Merge pull request #362 from Kobzol/test-suite-refactor
Refactor test suite to handle timeouts in a more robust way
2 parents 3e7a08b + 8d9e85d commit 2ab8f3a

File tree

10 files changed

+276
-264
lines changed

10 files changed

+276
-264
lines changed

src/bors/handlers/help.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ mod tests {
8383

8484
#[sqlx::test]
8585
async fn help_command(pool: sqlx::PgPool) {
86-
run_test(pool, |mut tester| async {
86+
run_test(pool, async |tester| {
8787
tester.post_comment("@bors help").await?;
8888
insta::assert_snapshot!(tester.get_comment().await?, @r"
8989
You can use the following commands:
@@ -119,7 +119,7 @@ mod tests {
119119
- `ping`: Check if the bot is alive
120120
- `help`: Print this help message
121121
");
122-
Ok(tester)
122+
Ok(())
123123
})
124124
.await;
125125
}

src/bors/handlers/info.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ mod tests {
6464

6565
#[sqlx::test]
6666
async fn info_for_unapproved_pr(pool: sqlx::PgPool) {
67-
run_test(pool, |mut tester| async {
67+
run_test(pool, async |tester| {
6868
tester.post_comment("@bors info").await?;
6969
insta::assert_snapshot!(
7070
tester.get_comment().await?,
@@ -75,14 +75,14 @@ mod tests {
7575
- Mergeable: yes
7676
"
7777
);
78-
Ok(tester)
78+
Ok(())
7979
})
8080
.await;
8181
}
8282

8383
#[sqlx::test]
8484
async fn info_for_approved_pr(pool: sqlx::PgPool) {
85-
run_test(pool, |mut tester| async {
85+
run_test(pool, async |tester| {
8686
tester.post_comment("@bors r+").await?;
8787
tester.expect_comments(1).await;
8888

@@ -96,14 +96,14 @@ mod tests {
9696
- Mergeable: yes
9797
"
9898
);
99-
Ok(tester)
99+
Ok(())
100100
})
101101
.await;
102102
}
103103

104104
#[sqlx::test]
105105
async fn info_for_pr_with_priority(pool: sqlx::PgPool) {
106-
run_test(pool, |mut tester| async {
106+
run_test(pool, async |tester| {
107107
tester.post_comment("@bors p=5").await?;
108108
tester
109109
.wait_for_default_pr(|pr| pr.priority == Some(5))
@@ -119,14 +119,14 @@ mod tests {
119119
- Mergeable: yes
120120
"
121121
);
122-
Ok(tester)
122+
Ok(())
123123
})
124124
.await;
125125
}
126126

127127
#[sqlx::test]
128128
async fn info_for_pr_with_try_build(pool: sqlx::PgPool) {
129-
run_test(pool, |mut tester| async {
129+
run_test(pool, async |tester| {
130130
tester.post_comment("@bors try").await?;
131131
tester.expect_comments(1).await;
132132

@@ -141,14 +141,14 @@ mod tests {
141141
- Try build is in progress
142142
"
143143
);
144-
Ok(tester)
144+
Ok(())
145145
})
146146
.await;
147147
}
148148

149149
#[sqlx::test]
150150
async fn info_for_pr_with_everything(pool: sqlx::PgPool) {
151-
run_test(pool, |mut tester| async {
151+
run_test(pool, async |tester| {
152152
tester.post_comment("@bors r+ p=10").await?;
153153
tester.expect_comments(1).await;
154154

@@ -171,7 +171,7 @@ mod tests {
171171
- Workflow URL: https://github.com/workflows/Workflow1/1
172172
"
173173
);
174-
Ok(tester)
174+
Ok(())
175175
})
176176
.await;
177177
}

src/bors/handlers/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -636,32 +636,32 @@ mod tests {
636636

637637
#[sqlx::test]
638638
async fn ignore_bot_comment(pool: sqlx::PgPool) {
639-
run_test(pool, |mut tester| async {
639+
run_test(pool, async |tester| {
640640
tester
641641
.post_comment(Comment::from("@bors ping").with_author(User::bors_bot()))
642642
.await?;
643643
// Returning here will make sure that no comments were received
644-
Ok(tester)
644+
Ok(())
645645
})
646646
.await;
647647
}
648648

649649
#[sqlx::test]
650650
async fn do_not_load_pr_on_unrelated_comment(pool: sqlx::PgPool) {
651-
run_test(pool, |mut tester| async {
651+
run_test(pool, async |tester| {
652652
tester.default_repo().lock().pull_request_error = true;
653653
tester.post_comment("no command").await?;
654-
Ok(tester)
654+
Ok(())
655655
})
656656
.await;
657657
}
658658

659659
#[sqlx::test]
660660
async fn unknown_command(pool: sqlx::PgPool) {
661-
run_test(pool, |mut tester| async {
661+
run_test(pool, async |tester| {
662662
tester.post_comment(Comment::from("@bors foo")).await?;
663663
insta::assert_snapshot!(tester.get_comment().await?, @r#"Unknown command "foo". Run `@bors help` to see available commands."#);
664-
Ok(tester)
664+
Ok(())
665665
})
666666
.await;
667667
}

src/bors/handlers/ping.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ mod tests {
2020

2121
#[sqlx::test]
2222
async fn ping_command(pool: sqlx::PgPool) {
23-
run_test(pool, |mut tester| async {
23+
run_test(pool, async |tester| {
2424
tester.post_comment("@bors ping").await?;
2525
assert_eq!(tester.get_comment().await?, "Pong 🏓!");
26-
Ok(tester)
26+
Ok(())
2727
})
2828
.await;
2929
}

0 commit comments

Comments
 (0)