Skip to content

Commit ff65eef

Browse files
committed
✅ Add test
1 parent 0b9f5da commit ff65eef

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

crates/uv/tests/it/pip_install.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,6 +1878,43 @@ fn install_extra_index_url_has_priority() {
18781878
context.assert_command("import flask").failure();
18791879
}
18801880

1881+
/// Ensure that the index is fetched only once when duplicate indices are specified
1882+
#[tokio::test]
1883+
async fn install_deduplicated_indices() {
1884+
let context = TestContext::new("3.12");
1885+
1886+
let redirect_server = MockServer::start().await;
1887+
1888+
Mock::given(method("GET"))
1889+
.respond_with(
1890+
ResponseTemplate::new(302).insert_header("Location", "https://pypi.org/simple/sniffio"),
1891+
)
1892+
.expect(1)
1893+
.mount(&redirect_server)
1894+
.await;
1895+
1896+
uv_snapshot!(context
1897+
.pip_install()
1898+
.arg("sniffio") // Use a zero-dependency package
1899+
.arg("--index")
1900+
.arg(redirect_server.uri())
1901+
.arg("--default-index")
1902+
.arg(redirect_server.uri())
1903+
.arg("--index-strategy")
1904+
.arg("unsafe-first-match"), // Anything but "first-index"
1905+
@r"
1906+
success: true
1907+
exit_code: 0
1908+
----- stdout -----
1909+
1910+
----- stderr -----
1911+
Resolved 1 package in [TIME]
1912+
Prepared 1 package in [TIME]
1913+
Installed 1 package in [TIME]
1914+
+ sniffio==1.3.1
1915+
");
1916+
}
1917+
18811918
/// Install a package from a public GitHub repository
18821919
#[test]
18831920
#[cfg(feature = "git")]

0 commit comments

Comments
 (0)