test(net): consolidate live API smoke tests
This commit is contained in:
1 parent
e21f68fd7c
commit
9b17ec96c5
9 files changed
+201
-249
No files matched your search
@@ -155,16 +155,6 @@ mod tests {
|
||||
assert_eq!(installer.loader_type(), loader);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore = "hits live Mojang API"]
|
||||
async fn test_vanilla_get_game_versions() {
|
||||
let client = HttpClient::new();
|
||||
let installer = VanillaInstaller;
|
||||
let versions = installer.get_game_versions(&client).await.unwrap();
|
||||
assert!(!versions.is_empty());
|
||||
assert!(versions.iter().any(|v| v.id == "1.20.1"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn save_installer_profile_copies_raw_bytes_verbatim() {
|
||||
use tempfile::TempDir;
|
||||
|
||||
@@ -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
@@ -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")
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -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}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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() {
|
||||
|
||||
@@ -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),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
//! Release-gate smoke tests for live upstream APIs.
|
||||
//!
|
||||
//! These are intentionally ignored during normal test runs. The release
|
||||
//! workflow runs them with `cargo test --all-targets -- --ignored`.
|
||||
|
||||
use rmcl::instance::{ModLoader, VanillaInstaller};
|
||||
use rmcl::net::{self, HttpClient};
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore = "hits live Fabric API"]
|
||||
async fn fabric_versions_are_available() {
|
||||
let client = HttpClient::new();
|
||||
let versions = net::fabric::fetch_fabric_versions(&client, "1.20.1")
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(!versions.is_empty());
|
||||
assert!(versions[0].loader.version.contains('.'));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore = "hits live Fabric API"]
|
||||
async fn fabric_game_versions_are_available() {
|
||||
let versions = net::fabric::fetch_fabric_game_versions(&HttpClient::new())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(versions.iter().any(|version| version.id == "1.20.1"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore = "hits live Quilt API"]
|
||||
async fn quilt_versions_are_available() {
|
||||
let versions = net::quilt::fetch_quilt_versions(&HttpClient::new(), "1.20.1")
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(!versions.is_empty());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore = "hits live Quilt API"]
|
||||
async fn quilt_game_versions_are_available() {
|
||||
let versions = net::quilt::fetch_quilt_game_versions(&HttpClient::new())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(versions.iter().any(|version| version.id == "1.20.1"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore = "hits live Forge API"]
|
||||
async fn forge_versions_are_available() {
|
||||
let versions = net::forge::fetch_forge_versions(&HttpClient::new(), "1.20.1")
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(!versions.is_empty());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore = "hits live Forge API"]
|
||||
async fn forge_game_versions_are_available() {
|
||||
let versions = net::forge::fetch_forge_game_versions(&HttpClient::new())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(versions.iter().any(|version| version.id == "1.20.1"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore = "hits live NeoForge API"]
|
||||
async fn neoforge_versions_are_available() {
|
||||
let versions = net::neoforge::fetch_neoforge_versions(&HttpClient::new(), "1.21")
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(!versions.is_empty());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore = "hits live NeoForge API"]
|
||||
async fn neoforge_game_versions_are_available() {
|
||||
let versions = net::neoforge::fetch_neoforge_game_versions(&HttpClient::new())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(versions.iter().any(|version| version.id == "1.21"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore = "hits live Mojang API"]
|
||||
async fn mojang_manifest_contains_a_known_release() {
|
||||
let manifest = net::mojang::fetch_version_manifest(&HttpClient::new())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(
|
||||
manifest
|
||||
.versions
|
||||
.iter()
|
||||
.any(|version| version.id == "1.20.1")
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore = "hits live Mojang API"]
|
||||
async fn vanilla_installer_lists_game_versions() {
|
||||
use rmcl::instance::ModLoaderInstaller;
|
||||
|
||||
let versions = VanillaInstaller
|
||||
.get_game_versions(&HttpClient::new())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(versions.iter().any(|version| version.id == "1.20.1"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore = "hits live Modrinth API"]
|
||||
async fn modrinth_project_is_available() {
|
||||
let project = net::modrinth::fetch_project(&HttpClient::new(), "fabulously-optimized")
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(project.slug, "fabulously-optimized");
|
||||
assert!(!project.title.is_empty());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore = "hits live Modrinth API"]
|
||||
async fn modrinth_versions_are_available() {
|
||||
let versions = net::modrinth::fetch_versions(&HttpClient::new(), "fabulously-optimized")
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(!versions.is_empty());
|
||||
assert!(!versions[0].files.is_empty());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore = "hits live Modrinth API"]
|
||||
async fn modrinth_discovery_returns_unique_compatible_mods() {
|
||||
use std::collections::HashSet;
|
||||
|
||||
use rmcl::net::modrinth::{DiscoveryKind, search_discovery};
|
||||
|
||||
let client = 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());
|
||||
|
||||
let mut seen = result
|
||||
.projects
|
||||
.iter()
|
||||
.map(|project| project.id.clone())
|
||||
.collect::<HashSet<_>>();
|
||||
for offset in (100..result.total_hits.min(300)).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}"
|
||||
);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// integration tests for the public mojang fetchers. wiremock stands in for
|
||||
// Mojang so tests are fast, deterministic, and don't depend on the live
|
||||
// endpoint. these are different from the #[ignore = "hits live Mojang API"]
|
||||
// tests in src/net/mojang.rs which verify the upstream schema hasn't drifted;
|
||||
// tests in tests/live_apis.rs which verify the upstream schema hasn't drifted;
|
||||
// these here verify our parsing + retry envelope on synthetic responses.
|
||||
|
||||
use serde_json::json;
|
||||
|
||||
Reference in new issue
Block a user