-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔨 Populate the guest cli args (#393)
Populate the guest cli args with the single value "compute-app". This should simplify adoption for languages that assume the args list is non-empty. Fixes #376
- Loading branch information
Showing
6 changed files
with
63 additions
and
5 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,46 @@ | ||
use crate::common::{Test, TestResult}; | ||
use hyper::{body::to_bytes, StatusCode}; | ||
|
||
/// Run a program that tests its args. This checks that we're populating the argument list with the | ||
/// singleton "compute-app" value. | ||
/// Check that an empty response is sent downstream by default. | ||
/// | ||
/// `args.wasm` is a guest program checks its cli args. | ||
#[tokio::test(flavor = "multi_thread")] | ||
async fn empty_ok_response_by_default_after_args() -> TestResult { | ||
let resp = Test::using_fixture("args.wasm").against_empty().await?; | ||
|
||
assert_eq!(resp.status(), StatusCode::OK); | ||
assert!(to_bytes(resp.into_body()) | ||
.await | ||
.expect("can read body") | ||
.to_vec() | ||
.is_empty()); | ||
|
||
Ok(()) | ||
} | ||
|
||
/// Run a program that tests its args. This checks that we're populating the argument list with the | ||
/// singleton "compute-app" value. | ||
/// Check that an empty response is sent downstream by default. | ||
/// | ||
/// `args.wasm` is a guest program checks its cli args. | ||
#[tokio::test(flavor = "multi_thread")] | ||
// TODO: The adapter needs to plumb through support for argument handling. This was removed | ||
// explicitly when we thought we would target the proxy world only, but we'll need it back to | ||
// simplify adapting programs from languages that need a non-empty args list. | ||
#[should_panic] | ||
async fn empty_ok_response_by_default_after_args_component() { | ||
let resp = Test::using_fixture("args.wasm") | ||
.adapt_component() | ||
.against_empty() | ||
.await | ||
.unwrap(); | ||
|
||
assert_eq!(resp.status(), StatusCode::OK); | ||
assert!(to_bytes(resp.into_body()) | ||
.await | ||
.expect("can read body") | ||
.to_vec() | ||
.is_empty()); | ||
} |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
mod args; | ||
mod async_io; | ||
mod body; | ||
mod client_certs; | ||
|
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
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
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
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,6 @@ | ||
fn main() { | ||
let args = Vec::from_iter(std::env::args()); | ||
|
||
assert_eq!(args.len(), 1); | ||
assert_eq!(args[0], "compute-app"); | ||
} |