Repository: tauri-apps/tauri
File: crates/tauri-bundler/src/bundle/windows/util.rs (Rust)

Code before:
  }

  Ok(())
}

#[cfg(target_os = "windows")]
pub fn os_bitness<'a>() -> Option<&'a str> {
  use windows_sys::Win32::System::SystemInformation::{
    GetNativeSystemInfo, PROCESSOR_ARCHITECTURE_AMD64, PROCESSOR_ARCHITECTURE_INTEL, SYSTEM_INFO,
  };

  let mut system_info: SYSTEM_INFO = unsafe { std::mem::zeroed() };
  unsafe { GetNativeSystemInfo(&mut system_info) };
  match unsafe { system_info.Anonymous.Anonymous.wProcessorArchitecture } {
    PROCESSOR_ARCHITECTURE_INTEL => Some("x86"),
    PROCESSOR_ARCHITECTURE_AMD64 => Some("x64"),
    _ => None,
  }
}

#[cfg(test)]
mod tests {
  use super::generate_mirror_url_from_template;
  use std::env;

  const URL: &str =
    "https://github.com/wixtoolset/wix3/releases/download/wix3112rtm/wix311-binaries.zip";

  #[test]
  fn test_generate_mirror_url_no_env_var() {
    env::remove_var("TAURI_BUNDLER_TOOLS_GITHUB_MIRROR_TEMPLATE");

    assert!(generate_mirror_url_from_template(URL).is_none());
  }

  #[test]
  fn test_generate_mirror_url_non_github_url() {
    env::set_var(
      "TAURI_BUNDLER_TOOLS_GITHUB_MIRROR_TEMPLATE",
      "https://mirror.example.com/<owner>/<repo>/releases/download/<version>/<asset>",
    );

    let url = "https://someotherwebsite.com/somefile.zip";
    assert!(generate_mirror_url_from_template(url).is_none());
  }

  #[test]
  fn test_generate_mirror_url_correctly1() {
    env::set_var(
      "TAURI_BUNDLER_TOOLS_GITHUB_MIRROR_TEMPLATE",
      "https://mirror.example.com/<owner>/<repo>/releases/download/<version>/<asset>",

Review comment (suggestion):
Let's call this `GOOD_URL`
```suggestion
  const GOOD_URL: &str =
```
and add another `BAD_URL` const next to it

Code after:
  let mut system_info: SYSTEM_INFO = unsafe { std::mem::zeroed() };
  unsafe { GetNativeSystemInfo(&mut system_info) };
  match unsafe { system_info.Anonymous.Anonymous.wProcessorArchitecture } {
    PROCESSOR_ARCHITECTURE_INTEL => Some("x86"),
    PROCESSOR_ARCHITECTURE_AMD64 => Some("x64"),
    _ => None,
  }
}

#[cfg(test)]
mod tests {
  use super::generate_github_mirror_url_from_template;
  use std::env;

  const GITHUB_ASSET_URL: &str =
    "https://github.com/wixtoolset/wix3/releases/download/wix3112rtm/wix311-binaries.zip";
  const NON_GITHUB_ASSET_URL: &str = "https://someotherwebsite.com/somefile.zip";

  #[test]
  fn test_generate_mirror_url_no_env_var() {
    env::remove_var("TAURI_BUNDLER_TOOLS_GITHUB_MIRROR_TEMPLATE");

    assert!(generate_github_mirror_url_from_template(GITHUB_ASSET_URL).is_none());
  }

  #[test]
  fn test_generate_mirror_url_non_github_url() {
    env::set_var(
      "TAURI_BUNDLER_TOOLS_GITHUB_MIRROR_TEMPLATE",
      "https://mirror.example.com/<owner>/<repo>/releases/download/<version>/<asset>",
    );

    assert!(generate_github_mirror_url_from_template(NON_GITHUB_ASSET_URL).is_none());
  }

  struct TestCase {
    template: &'static str,
    expected_url: &'static str,
  }

  #[test]
  fn test_generate_mirror_url_correctly() {
    let test_cases = vec![
            TestCase {
                template: "https://mirror.example.com/<owner>/<repo>/releases/download/<version>/<asset>",
                expected_url: "https://mirror.example.com/wixtoolset/wix3/releases/download/wix3112rtm/wix311-binaries.zip",
            },
            TestCase {
                template: "https://mirror.example.com/<asset>",
                expected_url: "https://mirror.example.com/wix311-binaries.zip",
            },