use anyhow::Result;
use assert_fs::fixture::ChildPath;
use insta::assert_snapshot;
use std::path::Path;
use uv_static::EnvVars;
static EXCLUDE_NEWER: &str = "2024-08-08T00:00:00Z";
#[test]
fn packse() -> Result<()> {
lock_ecosystem_package("3.12", "packse")
}
#[test]
fn github_wikidata_bot() -> Result<()> {
lock_ecosystem_package("3.12", "github-wikidata-bot")
}
#[test]
fn black() -> Result<()> {
lock_ecosystem_package("3.12", "black")
}
#[test]
fn home_assistant_core() -> Result<()> {
lock_ecosystem_package("3.12", "home-assistant-core")
}
#[test]
#[cfg(unix)] fn transformers() -> Result<()> {
if !cfg!(target_os = "linux") && std::env::var_os(EnvVars::CI).is_some() {
return Ok(());
}
lock_ecosystem_package("3.12", "transformers")
}
#[test]
fn warehouse() -> Result<()> {
if !cfg!(target_os = "linux") && std::env::var_os(EnvVars::CI).is_some() {
return Ok(());
}
lock_ecosystem_package("3.11", "warehouse")
}
#[test]
fn saleor() -> Result<()> {
lock_ecosystem_package("3.12", "saleor")
}
#[test]
#[ignore = "Airflow doesn't build with `uv` yet"]
fn airflow() -> Result<()> {
lock_ecosystem_package("3.12", "airflow")
}
fn lock_ecosystem_package(python_version: &str, name: &str) -> Result<()> {
let mut context = uv_test::test_context!(python_version);
context.copy_ecosystem_project(name);
let cache_dir =
std::path::absolute(Path::new("../../target/ecosystem-test-caches").join(name))?;
context.cache_dir = ChildPath::new(cache_dir);
let mut command = context.lock();
command.env(EnvVars::UV_EXCLUDE_NEWER, EXCLUDE_NEWER);
let (snapshot, _) = uv_test::run_and_format(
&mut command,
context.filters(),
name,
Some(uv_test::WindowsFilters::Platform),
None,
);
let lock = context.read("uv.lock");
insta::with_settings!({
filters => context.filters(),
}, {
assert_snapshot!(format!("{name}-lock-file"), lock);
});
assert_snapshot!(format!("{name}-uv-lock-output"), snapshot);
Ok(())
}