Skip to content

Commit

Permalink
Set the arguments for components as well
Browse files Browse the repository at this point in the history
  • Loading branch information
elliottt committed Jun 26, 2024
1 parent 3e8e42d commit 2ad7fc5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
20 changes: 20 additions & 0 deletions cli/tests/integration/args.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
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.
Expand All @@ -18,3 +19,22 @@ async fn empty_ok_response_by_default_after_args() -> TestResult {

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")]
async fn empty_ok_response_by_default_after_args_component() -> TestResult {
let resp = Test::using_fixture("args.wasm").adapt_component().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(())
}
6 changes: 4 additions & 2 deletions lib/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,10 @@ impl ExecuteCtx {
let req = session.downstream_request();
let body = session.downstream_request_body();

let mut store = ComponentCtx::create_store(&self, session, None, |_| {})
.map_err(ExecutionError::Context)?;
let mut store = ComponentCtx::create_store(&self, session, None, |ctx| {
ctx.arg("compute-app");
})
.map_err(ExecutionError::Context)?;

let (compute, _instance) =
compute::Compute::instantiate_pre(&mut store, instance_pre)
Expand Down

0 comments on commit 2ad7fc5

Please sign in to comment.