mirror of
https://git.ethanthesleepy.one/ethanaobrien/ew
synced 2026-10-12 01:24:27 +08:00
Add macos route and some other tests I guess
This commit is contained in:
+34
-2
@@ -49,6 +49,10 @@ static ASSET_VERSIONS: &[AssetVersion] = &[
|
||||
AssetVersion { region: "JP", platform: "Windows", version: "01a71b00f63e4dba92117ac7e60070a6", hash: "b8d0e7edcb63f5bdd28817a597772ca6", latest: true },
|
||||
AssetVersion { region: "JP", platform: "Android", version: "01a71b00f63e4dba92117ac7e60070a6", hash: "d12cecc5695da7f81f8873a3ff93752e", latest: true },
|
||||
AssetVersion { region: "JP", platform: "iOS", version: "01a71b00f63e4dba92117ac7e60070a6", hash: "7c1f61ee68ac84c82dd397a162629142", latest: true },
|
||||
// Linux / macOS players (StandaloneLinux64 / StandaloneOSX lanes): no baked hash, the
|
||||
// running build's hash is supplied with --linux-asset-hash / --mac-asset-hash
|
||||
AssetVersion { region: "JP", platform: "Linux", version: "01a71b00f63e4dba92117ac7e60070a6", hash: "", latest: true },
|
||||
AssetVersion { region: "JP", platform: "Mac", version: "01a71b00f63e4dba92117ac7e60070a6", hash: "", latest: true },
|
||||
|
||||
//AssetVersion { region: "JP", platform: "WebGL", version: "4c921d2443335e574a82e04ec9ea243c", hash: "e1ff7c74b20c8d216507972b6f24b9df", latest: true },
|
||||
];
|
||||
@@ -68,6 +72,8 @@ impl AssetVersion {
|
||||
let ov = args.asset_version.as_str();
|
||||
let oh = match (self.region, self.platform) {
|
||||
("JP", "Windows") => args.windows_asset_hash.as_str(),
|
||||
("JP", "Linux") => args.linux_asset_hash.as_str(),
|
||||
("JP", "Mac") => args.mac_asset_hash.as_str(),
|
||||
("JP", "Android") => args.jp_android_asset_hash.as_str(),
|
||||
("JP", "iOS") => args.jp_ios_asset_hash.as_str(),
|
||||
("GL", "Android") => args.en_android_asset_hash.as_str(),
|
||||
@@ -89,7 +95,7 @@ fn valid_hashes(asset_version: &str, platform: &str) -> Vec<String> {
|
||||
if entry.platform != platform {
|
||||
continue;
|
||||
}
|
||||
if entry.version == asset_version {
|
||||
if entry.version == asset_version && !entry.hash.is_empty() {
|
||||
out.push(entry.stock_hash());
|
||||
}
|
||||
if entry.latest {
|
||||
@@ -116,7 +122,7 @@ fn preferred_hash(asset_version: &str, platform: &str) -> Option<String> {
|
||||
}
|
||||
}
|
||||
}
|
||||
if entry.version == asset_version && stock.is_none() {
|
||||
if entry.version == asset_version && stock.is_none() && !entry.hash.is_empty() {
|
||||
stock = Some(entry.stock_hash());
|
||||
}
|
||||
}
|
||||
@@ -169,6 +175,8 @@ pub fn parse_platform(header: &str) -> &str {
|
||||
"iphone" => "iOS",
|
||||
"windows" => "Windows",
|
||||
"windowsplayer" => "Windows",
|
||||
"linuxplayer" => "Linux",
|
||||
"osxplayer" => "Mac",
|
||||
"webglplayer" => "WebGL",
|
||||
"editor" => "Editor",
|
||||
"windowseditor" => "Editor",
|
||||
@@ -471,3 +479,27 @@ pub(crate) fn get_cards(arr: JsonValue, user: &JsonValue) -> JsonValue {
|
||||
}
|
||||
rv
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod platform_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn standalone_player_platforms_are_known() {
|
||||
assert_eq!(parse_platform("WindowsPlayer"), "Windows");
|
||||
assert_eq!(parse_platform("LinuxPlayer"), "Linux");
|
||||
assert_eq!(parse_platform("OSXPlayer"), "Mac");
|
||||
assert_eq!(parse_platform("OSXEditor"), "Editor");
|
||||
}
|
||||
|
||||
// Linux / macOS have no baked hash: without the CLI override the platform has no valid
|
||||
// hash at all (never an empty string presented as one)
|
||||
#[test]
|
||||
fn unhashed_platforms_answer_nothing_without_an_override() {
|
||||
let latest = ASSET_VERSIONS.iter().find(|e| e.latest && e.platform == "Windows").unwrap().version;
|
||||
assert_eq!(preferred_hash(latest, "Mac"), None);
|
||||
assert_eq!(preferred_hash(latest, "Linux"), None);
|
||||
assert!(valid_hashes(latest, "Mac").is_empty());
|
||||
assert!(preferred_hash(latest, "Windows").is_some());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user