//! DO NOT EDIT
//!
//! Generated with `{{generated_with}}`
//! Scenarios from <{{generated_from}}>
//!
#![cfg(all(feature = "python", feature = "pypi"))]
#![allow(clippy::needless_raw_string_hashes)]
#![allow(clippy::doc_markdown)]
#![allow(clippy::doc_lazy_continuation)]

use anyhow::Result;
use assert_cmd::assert::OutputAssertExt;
use assert_fs::prelude::*;
use insta::assert_snapshot;

use uv_static::EnvVars;

use crate::common::{TestContext, packse_index_url, uv_snapshot};

{{#scenarios}}

/// {{description}}
///
/// ```text
/// {{name}}
{{#tree}}
/// {{.}}
{{/tree}}
/// ```
#[test]
fn {{module_name}}() -> Result<()> {
    let context = TestContext::new("{{environment.python}}");

    // In addition to the standard filters, swap out package names for shorter messages
    let mut filters = context.filters();
    filters.push((r"{{name}}-", "package-"));

    let pyproject_toml = context.temp_dir.child("pyproject.toml");
    pyproject_toml.write_str(
        r###"
        [project]
        name = "project"
        version = "0.1.0"
        dependencies = [
          {{#root.requires}}
          '''{{requirement}}''',
          {{/root.requires}}
        ]
        {{#root.requires_python}}
        requires-python = "{{.}}"
        {{/root.requires_python}}
        {{#resolver_options.has_required_environments}}
        [tool.uv]
        required-environments = [
          {{#resolver_options.required_environments}}
          '''{{.}}''',
          {{/resolver_options.required_environments}}
        ]
        {{/resolver_options.has_required_environments}}
        "###
    )?;

    let mut cmd = context.lock();
    cmd.env_remove(EnvVars::UV_EXCLUDE_NEWER);
    cmd.arg("--index-url").arg(packse_index_url());
    {{#expected.explanation}}
    // {{expected.explanation}}
    {{/expected.explanation}}
    uv_snapshot!(filters, cmd, @r###"<snapshot>
    "###
    );

    {{#expected.satisfiable}}
    let lock = context.read("uv.lock");
    insta::with_settings!({
        filters => filters,
    }, {
        assert_snapshot!(
            lock, @r###"<snapshot>
            "###
        );
    });

    // Assert the idempotence of `uv lock` when resolving from the lockfile (`--locked`).
    context
        .lock()
        .arg("--locked")
        .env_remove(EnvVars::UV_EXCLUDE_NEWER)
        .arg("--index-url")
        .arg(packse_index_url())
        .assert()
        .success();
    {{/expected.satisfiable}}

    Ok(())
}
{{/scenarios}}
