test(net): consolidate live API smoke tests

This commit is contained in:
objz committed 2026-07-27 00:38:03 +02:00
1 parent e21f68fd7c
commit 9b17ec96c5
9 files changed
+201 -249

No files matched your search

-38
View File
@@ -193,41 +193,3 @@ pub async fn download_fabric_libraries(
tracing::debug!("Fabric library resolution complete for {}", profile.id);
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
use crate::net::HttpClient;
#[tokio::test]
#[ignore = "hits live Fabric API"]
async fn test_fetch_versions() {
let client = HttpClient::new();
match fetch_fabric_versions(&client, "1.20.1").await {
Ok(versions) => {
assert!(
!versions.is_empty(),
"Should have Fabric versions for 1.20.1"
);
assert!(
versions[0].loader.version.contains('.'),
"Version should be semver-like"
);
}
Err(e) => panic!("fetch_fabric_versions failed: {}", e),
}
}
#[tokio::test]
#[ignore = "hits live Fabric API"]
async fn test_fetch_game_versions() {
let client = HttpClient::new();
match fetch_fabric_game_versions(&client).await {
Ok(versions) => {
assert!(!versions.is_empty(), "Should have Fabric game versions");
assert!(versions.iter().any(|version| version.id == "1.20.1"));
}
Err(e) => panic!("fetch_fabric_game_versions failed: {}", e),
}
}
}
+4 -32
View File
@@ -378,35 +378,6 @@ pub(crate) async fn install_forge_from_profile(
#[cfg(test)]
mod tests {
use super::*;
use crate::net::HttpClient;
#[tokio::test]
#[ignore = "hits live Forge API"]
async fn test_fetch_versions() {
let client = HttpClient::new();
match fetch_forge_versions(&client, "1.20.1").await {
Ok(versions) => {
assert!(
!versions.is_empty(),
"Should have Forge versions for 1.20.1"
);
}
Err(e) => panic!("fetch_forge_versions failed: {}", e),
}
}
#[tokio::test]
#[ignore = "hits live Forge API"]
async fn test_fetch_game_versions() {
let client = HttpClient::new();
match fetch_forge_game_versions(&client).await {
Ok(versions) => {
assert!(!versions.is_empty(), "Should have Forge game versions");
assert!(versions.iter().any(|version| version.id == "1.20.1"));
}
Err(e) => panic!("fetch_forge_game_versions failed: {}", e),
}
}
// builds an in-memory zip in a tempdir with the given json as
// install_profile.json. lets the legacy-install-profile detector be
@@ -456,8 +427,9 @@ mod tests {
#[test]
fn has_legacy_install_profile_false_for_missing_jar() {
assert!(!has_legacy_install_profile(std::path::Path::new(
"/nonexistent/installer.jar"
)));
let tmp = tempfile::tempdir().unwrap();
assert!(!has_legacy_install_profile(
&tmp.path().join("missing-installer.jar")
));
}
}
-86
View File
@@ -768,64 +768,6 @@ mod tests {
assert!(DiscoveryProject::from(hit).icon_url.is_none());
}
#[tokio::test]
#[ignore = "hits live Modrinth API"]
async fn search_discovery_returns_compatible_mods() {
let client = crate::net::HttpClient::new();
let result = search_discovery(
&client,
DiscoveryKind::Mod,
"sodium",
"1.21.1",
ModLoader::Fabric,
0,
100,
)
.await
.unwrap();
assert!(!result.projects.is_empty());
assert!(result.total_hits >= result.projects.len());
let icon_url = result
.projects
.iter()
.find_map(|project| project.icon_url.as_deref())
.expect("expected at least one project icon");
let icon = client.get_bytes(icon_url).await.unwrap();
assert!(
image::load_from_memory(&icon).is_ok(),
"failed to decode {icon_url}; first bytes: {:?}",
icon.get(..icon.len().min(16))
);
let mut seen = result
.projects
.iter()
.map(|project| project.id.clone())
.collect::<std::collections::HashSet<_>>();
let end = result.total_hits.min(300);
for offset in (100..end).step_by(100) {
let next = search_discovery(
&client,
DiscoveryKind::Mod,
"sodium",
"1.21.1",
ModLoader::Fabric,
offset,
100,
)
.await
.unwrap();
assert!(!next.projects.is_empty(), "empty page at offset {offset}");
assert!(
next.projects
.iter()
.all(|project| seen.insert(project.id.clone())),
"duplicate project at offset {offset}"
);
}
}
// covers each branch of url_encode: unreserved bytes pass through; the
// reserved set + spaces + non-ascii bytes get percent-encoded. emoji
// exercises multi-byte UTF-8 since the encoder operates on bytes, not
@@ -908,32 +850,4 @@ mod tests {
Some("1.21.4".to_string())
);
}
#[tokio::test]
#[ignore = "hits live Modrinth API"]
async fn test_fetch_project() {
let client = crate::net::HttpClient::new();
let project = fetch_project(&client, "fabulously-optimized").await;
match project {
Ok(p) => {
assert_eq!(p.slug, "fabulously-optimized");
assert!(!p.title.is_empty());
}
Err(e) => panic!("fetch_project failed: {e}"),
}
}
#[tokio::test]
#[ignore = "hits live Modrinth API"]
async fn test_fetch_versions() {
let client = crate::net::HttpClient::new();
let versions = fetch_versions(&client, "fabulously-optimized").await;
match versions {
Ok(v) => {
assert!(!v.is_empty());
assert!(!v[0].files.is_empty());
}
Err(e) => panic!("fetch_versions failed: {e}"),
}
}
}
-19
View File
@@ -447,22 +447,3 @@ fn spawn_download_task(
})
});
}
#[cfg(test)]
mod tests {
use super::*;
use crate::net::HttpClient;
#[tokio::test]
#[ignore = "hits live Mojang API"]
async fn test_fetch_manifest_contains_1_20_1() {
let client = HttpClient::new();
match fetch_version_manifest(&client).await {
Ok(manifest) => {
let found = manifest.versions.iter().any(|v| v.id == "1.20.1");
assert!(found, "1.20.1 should be in the manifest");
}
Err(e) => panic!("fetch_version_manifest failed: {}", e),
}
}
}
-29
View File
@@ -220,35 +220,6 @@ pub async fn run_neoforge_installer(
#[cfg(test)]
mod tests {
use super::*;
use crate::net::HttpClient;
#[tokio::test]
#[ignore = "hits live NeoForge API"]
async fn test_fetch_versions() {
let client = HttpClient::new();
match fetch_neoforge_versions(&client, "1.21").await {
Ok(versions) => {
assert!(
!versions.is_empty(),
"Should have NeoForge versions for 1.21"
);
}
Err(e) => panic!("fetch_neoforge_versions failed: {}", e),
}
}
#[tokio::test]
#[ignore = "hits live NeoForge API"]
async fn test_fetch_game_versions() {
let client = HttpClient::new();
match fetch_neoforge_game_versions(&client).await {
Ok(versions) => {
assert!(!versions.is_empty(), "Should have NeoForge game versions");
assert!(versions.iter().any(|version| version.id == "1.21"));
}
Err(e) => panic!("fetch_neoforge_game_versions failed: {}", e),
}
}
#[test]
fn test_game_version_to_neoforge_prefix() {
-34
View File
@@ -187,37 +187,3 @@ pub async fn download_quilt_libraries(
tracing::debug!("Quilt library resolution complete for {}", profile.id);
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
use crate::net::HttpClient;
#[tokio::test]
#[ignore = "hits live Quilt API"]
async fn test_fetch_versions() {
let client = HttpClient::new();
match fetch_quilt_versions(&client, "1.20.1").await {
Ok(versions) => {
assert!(
!versions.is_empty(),
"Should have Quilt versions for 1.20.1"
);
}
Err(e) => panic!("fetch_quilt_versions failed: {}", e),
}
}
#[tokio::test]
#[ignore = "hits live Quilt API"]
async fn test_fetch_game_versions() {
let client = HttpClient::new();
match fetch_quilt_game_versions(&client).await {
Ok(versions) => {
assert!(!versions.is_empty(), "Should have Quilt game versions");
assert!(versions.iter().any(|version| version.id == "1.20.1"));
}
Err(e) => panic!("fetch_quilt_game_versions failed: {}", e),
}
}
}