Add tests for empty index URL environment variable (#2141)
This commit is contained in:
@@ -4517,3 +4517,124 @@ fn editable_direct_dependency() -> Result<()> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Setting `UV_INDEX_URL` to the empty string should treat it as "unset".
|
||||
#[test]
|
||||
fn empty_index_url_env_var() -> Result<()> {
|
||||
let context = TestContext::new("3.12");
|
||||
let requirements_in = context.temp_dir.child("requirements.in");
|
||||
requirements_in.write_str("anyio")?;
|
||||
|
||||
uv_snapshot!(context.compile()
|
||||
.arg("requirements.in")
|
||||
.arg("--emit-index-url")
|
||||
.env("UV_INDEX_URL", ""), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile --cache-dir [CACHE_DIR] --exclude-newer 2023-11-18T12:00:00Z requirements.in --emit-index-url
|
||||
--index-url https://pypi.org/simple
|
||||
|
||||
anyio==4.0.0
|
||||
idna==3.4
|
||||
# via anyio
|
||||
sniffio==1.3.0
|
||||
# via anyio
|
||||
|
||||
----- stderr -----
|
||||
Resolved 3 packages in [TIME]
|
||||
"###
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Setting `EXTRA_UV_INDEX_URL` to the empty string should treat it as "unset".
|
||||
#[test]
|
||||
fn empty_extra_index_url_env_var() -> Result<()> {
|
||||
let context = TestContext::new("3.12");
|
||||
let requirements_in = context.temp_dir.child("requirements.in");
|
||||
requirements_in.write_str("anyio")?;
|
||||
|
||||
uv_snapshot!(context.compile()
|
||||
.arg("requirements.in")
|
||||
.arg("--emit-index-url")
|
||||
.env("EXTRA_UV_INDEX_URL", ""), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile --cache-dir [CACHE_DIR] --exclude-newer 2023-11-18T12:00:00Z requirements.in --emit-index-url
|
||||
--index-url https://pypi.org/simple
|
||||
|
||||
anyio==4.0.0
|
||||
idna==3.4
|
||||
# via anyio
|
||||
sniffio==1.3.0
|
||||
# via anyio
|
||||
|
||||
----- stderr -----
|
||||
Resolved 3 packages in [TIME]
|
||||
"###
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Setting `UV_INDEX_URL` to the empty string should treat it as "unset", and so should be
|
||||
/// overridden by an `--index-url` in a requirements file.
|
||||
#[test]
|
||||
fn empty_index_url_env_var_override() -> Result<()> {
|
||||
let context = TestContext::new("3.12");
|
||||
let requirements_in = context.temp_dir.child("requirements.in");
|
||||
requirements_in.write_str("--index-url https://test.pypi.org/simple\nidna")?;
|
||||
|
||||
uv_snapshot!(context.compile()
|
||||
.arg("requirements.in")
|
||||
.arg("--emit-index-url")
|
||||
.env("UV_INDEX_URL", ""), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile --cache-dir [CACHE_DIR] --exclude-newer 2023-11-18T12:00:00Z requirements.in --emit-index-url
|
||||
--index-url https://test.pypi.org/simple
|
||||
|
||||
idna==2.7
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
"###
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The `UV_INDEX_URL` should override an `--index-url` in a requirements file.
|
||||
#[test]
|
||||
fn index_url_env_var_override() -> Result<()> {
|
||||
let context = TestContext::new("3.12");
|
||||
let requirements_in = context.temp_dir.child("requirements.in");
|
||||
requirements_in.write_str("--index-url https://pypi.org/simple\nidna")?;
|
||||
|
||||
uv_snapshot!(context.compile()
|
||||
.arg("requirements.in")
|
||||
.arg("--emit-index-url")
|
||||
.env("UV_INDEX_URL", "https://test.pypi.org/simple"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile --cache-dir [CACHE_DIR] --exclude-newer 2023-11-18T12:00:00Z requirements.in --emit-index-url
|
||||
--index-url https://test.pypi.org/simple
|
||||
|
||||
idna==2.7
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
"###
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user