-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test new architecture on win.rustup.rs
A new architecture was just added to `win.rustup.rs`, which is now also covered by a smoke test.
- Loading branch information
Showing
2 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
//! Test `win.rustup.rs/aarch64` | ||
use async_trait::async_trait; | ||
|
||
use crate::rustup::win_rustup_rs::request_installer_and_expect_attachment; | ||
use crate::test::{Test, TestResult}; | ||
|
||
use super::config::Config; | ||
|
||
/// The name of the test | ||
const NAME: &str = "aarch64"; | ||
|
||
/// Test that `win.rustup.rs/aarch64` serves the Rustup installer | ||
/// | ||
/// This test requests the installer from `win.rustup.rs/aarch64` and expects the response to contain | ||
/// the correct file as an attachment. | ||
pub struct Aarch64<'a> { | ||
/// Configuration for this test | ||
config: &'a Config, | ||
} | ||
|
||
impl<'a> Aarch64<'a> { | ||
/// Create a new instance of the test | ||
pub fn new(config: &'a Config) -> Self { | ||
Self { config } | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl<'a> Test for Aarch64<'a> { | ||
async fn run(&self) -> TestResult { | ||
request_installer_and_expect_attachment( | ||
NAME, | ||
&format!("{}/aarch64", self.config.cloudfront_url()), | ||
) | ||
.await | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use crate::test_utils::*; | ||
|
||
use super::*; | ||
|
||
#[tokio::test] | ||
async fn succeeds_with_http_200_and_attachment() { | ||
let mut server = mockito::Server::new_async().await; | ||
|
||
let config = Config::builder().cloudfront_url(server.url()).build(); | ||
|
||
let mock = server | ||
.mock("HEAD", "/aarch64") | ||
.with_status(200) | ||
.with_header("Content-Type", "application/x-msdownload") | ||
.with_header( | ||
"Content-Disposition", | ||
r#"attachment; filename="rustup-init.exe""#, | ||
) | ||
.create(); | ||
|
||
let result = Aarch64::new(&config).run().await; | ||
|
||
// Assert that the mock was called | ||
mock.assert(); | ||
|
||
assert_eq!(&None, result.message()); | ||
assert!(result.success()); | ||
} | ||
|
||
#[tokio::test] | ||
async fn fails_without_content_type() { | ||
let mut server = mockito::Server::new_async().await; | ||
|
||
let config = Config::builder().cloudfront_url(server.url()).build(); | ||
|
||
let mock = server | ||
.mock("HEAD", "/aarch64") | ||
.with_status(200) | ||
.with_header( | ||
"Content-Disposition", | ||
r#"attachment; filename="rustup-init.exe""#, | ||
) | ||
.create(); | ||
|
||
let result = Aarch64::new(&config).run().await; | ||
|
||
// Assert that the mock was called | ||
mock.assert(); | ||
|
||
let message = result.message().as_ref().unwrap(); | ||
|
||
assert!(message.contains("Content-Type")); | ||
assert!(!result.success()); | ||
} | ||
|
||
#[tokio::test] | ||
async fn fails_without_content_disposition() { | ||
let mut server = mockito::Server::new_async().await; | ||
|
||
let config = Config::builder().cloudfront_url(server.url()).build(); | ||
|
||
let mock = server | ||
.mock("HEAD", "/aarch64") | ||
.with_status(200) | ||
.with_header("Content-Type", "application/x-msdownload") | ||
.create(); | ||
|
||
let result = Aarch64::new(&config).run().await; | ||
|
||
// Assert that the mock was called | ||
mock.assert(); | ||
|
||
let message = result.message().as_ref().unwrap(); | ||
|
||
assert!(message.contains("Content-Disposition")); | ||
assert!(!result.success()); | ||
} | ||
|
||
#[test] | ||
fn trait_send() { | ||
assert_send::<Aarch64>(); | ||
} | ||
|
||
#[test] | ||
fn trait_sync() { | ||
assert_sync::<Aarch64>(); | ||
} | ||
|
||
#[test] | ||
fn trait_unpin() { | ||
assert_unpin::<Aarch64>(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters