Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: assert stable installer script URLs #321

Merged
merged 3 commits into from
Mar 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions tests/installers.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
use std::fs;
use std::path::PathBuf;
use std::process::Command;

use serde_json::Value;

// The behavior of these tests _must_ remain unchanged
// should we want our installer scripts to remain stable.

// Ensures the nix installer exists at a stable location.
#[test]
fn it_has_nix_installer() {
let nix_installer_path = get_binstall_scripts_root().join("nix").join("install.sh");
let nix_script =
fs::read_to_string(&nix_installer_path).expect("Could not read nix installer script");
assert!(!nix_script.is_empty())
}

// Ensures the windows installer exists at a stable location.
#[test]
fn it_has_windows_installer() {
let windows_installer_path = get_binstall_scripts_root()
.join("windows")
.join("install.ps1");
let windows_script = fs::read_to_string(&windows_installer_path)
.expect("Could not read windows installer script");
assert!(!windows_script.is_empty())
}

fn get_binstall_scripts_root() -> PathBuf {
let cargo_locate_project_output = Command::new("cargo")
.arg("locate-project")
.output()
.expect("Could not run `cargo locate-project`");

let cargo_locate_project_json: Value =
serde_json::from_slice(&cargo_locate_project_output.stdout)
.expect("Could not parse JSON output of `cargo locate-project`");

let cargo_toml_location = cargo_locate_project_json["root"]
.as_str()
.expect("`root` either does not exist or is not a String");

let root_directory = PathBuf::from(cargo_toml_location)
.parent()
.expect("Could not find parent of `Cargo.toml`")
.to_path_buf();

root_directory
.join("installers")
.join("binstall")
.join("scripts")
}