Skip to content

Commit 8901c38

Browse files
committed
Regression tests
1 parent 473039a commit 8901c38

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed

src/tests/worker/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
mod git;
2+
mod readmes;
23
mod rss;
4+
mod send_publish_notifications;
35
mod sync_admins;
6+
mod update_default_version;

src/tests/worker/readmes.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use crate::tests::util::TestApp;
2+
use crate::worker::jobs;
3+
use crates_io_worker::BackgroundJob;
4+
5+
#[tokio::test(flavor = "multi_thread")]
6+
async fn skips_when_crate_deleted() -> anyhow::Result<()> {
7+
let (app, _) = TestApp::full().empty().await;
8+
let mut conn = app.db_conn().await;
9+
10+
let job =
11+
jobs::RenderAndUploadReadme::new(-1, "deleted".to_string(), ".".to_string(), None, None);
12+
13+
job.enqueue(&mut conn).await?;
14+
app.run_pending_background_jobs().await;
15+
16+
Ok(())
17+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
use crate::tests::util::TestApp;
2+
use crate::worker::jobs;
3+
use crates_io_worker::BackgroundJob;
4+
5+
#[tokio::test(flavor = "multi_thread")]
6+
async fn skips_when_crate_deleted() -> anyhow::Result<()> {
7+
let (app, _) = TestApp::full().empty().await;
8+
let mut conn = app.db_conn().await;
9+
10+
let job = jobs::SendPublishNotificationsJob::new(-1);
11+
12+
job.enqueue(&mut conn).await?;
13+
app.run_pending_background_jobs().await;
14+
15+
Ok(())
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
use crate::tests::util::TestApp;
2+
use crate::worker::jobs;
3+
use crates_io_worker::BackgroundJob;
4+
5+
#[tokio::test(flavor = "multi_thread")]
6+
async fn skips_when_crate_deleted() -> anyhow::Result<()> {
7+
let (app, _) = TestApp::full().empty().await;
8+
let mut conn = app.db_conn().await;
9+
10+
let job = jobs::UpdateDefaultVersion::new(-1);
11+
12+
job.enqueue(&mut conn).await?;
13+
app.run_pending_background_jobs().await;
14+
15+
Ok(())
16+
}

0 commit comments

Comments
 (0)