You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
119 lines
4.4 KiB
119 lines
4.4 KiB
use mclaunch::manifest::*;
|
|
|
|
#[test]
|
|
fn test_arguments() {
|
|
let src = r#"
|
|
{
|
|
"game": [
|
|
{
|
|
"rules": [
|
|
],
|
|
"value": [
|
|
"--quickPlayRealms",
|
|
"${quickPlayRealms}"
|
|
]
|
|
}
|
|
],
|
|
"jvm": [
|
|
]
|
|
}
|
|
"#;
|
|
let arguments: Arguments = serde_json::from_str(src).unwrap();
|
|
println!("{:#?}", arguments);
|
|
}
|
|
|
|
#[test]
|
|
fn test_basic_decode() {
|
|
// Grab minecraft version manifest
|
|
let response = ureq::get("https://launchermeta.mojang.com/mc/game/version_manifest.json").call();
|
|
let version_manifest = response.unwrap().into_string().unwrap();
|
|
// Deserialize the version manifest
|
|
let version_manifest: VersionManifest = serde_json::from_str(&version_manifest).unwrap();
|
|
// Print the version manifest
|
|
println!("{:#?}", version_manifest);
|
|
// fetch the latest release version
|
|
let latest_release = &version_manifest.latest.release;
|
|
// Print the latest release version
|
|
println!("Latest release version: {}", latest_release);
|
|
// Fetch the Version struct for the latest release version
|
|
let latest_release_version = version_manifest.versions.iter().find(
|
|
|version| version.id.as_str() == latest_release.as_str())
|
|
.unwrap();
|
|
// Print the latest release version struct
|
|
println!("{:#?}", latest_release_version);
|
|
|
|
// Fetch the version manifest for the latest release version
|
|
let response = ureq::get(&latest_release_version.url).call();
|
|
let version_json = response.unwrap().into_string().unwrap();
|
|
// Print the version manifest for the latest release version
|
|
println!("{}", version_json);
|
|
// Deserialize the version manifest for the latest release version
|
|
let version_json: VersionJson = serde_json::from_str(&version_json).unwrap();
|
|
// Print the version manifest for the latest release version
|
|
println!("{:#?}", version_json);
|
|
// Grab the asset index url
|
|
let asset_index_url = &version_json.asset_index.url;
|
|
// Print the asset index url
|
|
println!("Asset index url: {}", asset_index_url);
|
|
// Fetch the asset index
|
|
let response = ureq::get(asset_index_url).call();
|
|
let asset_index = response.unwrap().into_string().unwrap();
|
|
// Print the asset index
|
|
println!("{}", asset_index);
|
|
// Deserialize the asset index
|
|
let asset_index: AssetIndex = serde_json::from_str(&asset_index).unwrap();
|
|
// Print the asset index
|
|
println!("{:#?}", asset_index);
|
|
}
|
|
|
|
#[test]
|
|
fn test_164_decode() {
|
|
// Grab minecraft version manifest
|
|
let response = ureq::get("https://launchermeta.mojang.com/mc/game/version_manifest.json").call();
|
|
let version_manifest = response.unwrap().into_string().unwrap();
|
|
// Deserialize the version manifest
|
|
let version_manifest: VersionManifest = serde_json::from_str(&version_manifest).unwrap();
|
|
// Print the version manifest
|
|
println!("{:#?}", version_manifest);
|
|
// fetch the 1.6.4 version
|
|
let version_164 = version_manifest.versions.iter().find(
|
|
|version| version.id.as_str() == "1.6.4")
|
|
.unwrap();
|
|
// Print the 1.6.4 version
|
|
println!("{:#?}", version_164);
|
|
|
|
// Fetch the version manifest for the 1.6.4 version
|
|
let response = ureq::get(&version_164.url).call();
|
|
let version_json = response.unwrap().into_string().unwrap();
|
|
// Print the version manifest for the 1.6.4 version
|
|
println!("{}", version_json);
|
|
// Deserialize the version manifest for the 1.6.4 version
|
|
let version_json: VersionJson = serde_json::from_str(&version_json).unwrap();
|
|
// Print the version manifest for the 1.6.4 version
|
|
println!("{:#?}", version_json);
|
|
// Grab the asset index url
|
|
let asset_index_url = &version_json.asset_index.url;
|
|
// Print the asset index url
|
|
println!("Asset index url: {}", asset_index_url);
|
|
// Fetch the asset index
|
|
let response = ureq::get(asset_index_url).call();
|
|
let asset_index = response.unwrap().into_string().unwrap();
|
|
// Print the asset index
|
|
println!("{}", asset_index);
|
|
// Deserialize the asset index
|
|
let asset_index: AssetIndex = serde_json::from_str(&asset_index).unwrap();
|
|
// Print the asset index
|
|
println!("{:#?}", asset_index);
|
|
}
|
|
|
|
#[test]
|
|
fn test_latest_decode() {
|
|
let latest = mclaunch::get_latest_version().unwrap();
|
|
let _asset_index = latest.get_asset_index().unwrap();
|
|
}
|
|
|
|
#[test]
|
|
fn test_164_decode_latest() {
|
|
let version_164 = mclaunch::fetch_version("1.6.4").unwrap();
|
|
let _asset_index = version_164.get_asset_index().unwrap();
|
|
} |