Skip to content

Commit b60f614

Browse files
committed
tests
1 parent f4a22e5 commit b60f614

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

src/build_queue.rs

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,9 +889,10 @@ mod tests {
889889
use crate::db::types::BuildStatus;
890890
use crate::test::{FakeBuild, TestEnvironment, V1, V2};
891891
use chrono::Utc;
892-
893892
use std::time::Duration;
894893

894+
static KRATE: &str = "krate";
895+
895896
#[tokio::test(flavor = "multi_thread")]
896897
async fn test_rebuild_when_old() -> Result<()> {
897898
let env = TestEnvironment::with_config(
@@ -1757,4 +1758,48 @@ mod tests {
17571758

17581759
Ok(())
17591760
}
1761+
1762+
#[tokio::test(flavor = "multi_thread")]
1763+
async fn test_delete_version_from_queue() -> Result<()> {
1764+
let env = TestEnvironment::new().await?;
1765+
1766+
let queue = env.async_build_queue();
1767+
assert_eq!(queue.pending_count().await?, 0);
1768+
1769+
queue.add_crate(KRATE, &V1, 0, None).await?;
1770+
queue.add_crate(KRATE, &V2, 0, None).await?;
1771+
1772+
assert_eq!(queue.pending_count().await?, 2);
1773+
queue.remove_version_from_queue(KRATE, &V1).await?;
1774+
1775+
assert_eq!(queue.pending_count().await?, 1);
1776+
1777+
// only v2 remains
1778+
if let [k] = queue.queued_crates().await?.as_slice() {
1779+
assert_eq!(k.name, KRATE);
1780+
assert_eq!(k.version, V2);
1781+
} else {
1782+
panic!("expected only one queued crate");
1783+
}
1784+
1785+
Ok(())
1786+
}
1787+
1788+
#[tokio::test(flavor = "multi_thread")]
1789+
async fn test_delete_crate_from_queue() -> Result<()> {
1790+
let env = TestEnvironment::new().await?;
1791+
1792+
let queue = env.async_build_queue();
1793+
assert_eq!(queue.pending_count().await?, 0);
1794+
1795+
queue.add_crate(KRATE, &V1, 0, None).await?;
1796+
queue.add_crate(KRATE, &V2, 0, None).await?;
1797+
1798+
assert_eq!(queue.pending_count().await?, 2);
1799+
queue.remove_crate_from_queue(KRATE).await?;
1800+
1801+
assert_eq!(queue.pending_count().await?, 0);
1802+
1803+
Ok(())
1804+
}
17601805
}

0 commit comments

Comments
 (0)