Skip to content

Commit

Permalink
The rest of the factor tests
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Levick <[email protected]>
  • Loading branch information
rylev committed Jul 26, 2024
1 parent 2e72b68 commit 4a3daec
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion crates/factor-llm/tests/factor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async fn llm_works() -> anyhow::Result<()> {
source = "does-not-exist.wasm"
ai_models = ["llama2-chat"]
});
let mut state = env.build_instance_state(factors).await?;
let mut state = env.build_instance_state(factors, ()).await?;
assert_eq!(
&*state.llm.allowed_models,
&["llama2-chat".to_owned()]
Expand Down
2 changes: 1 addition & 1 deletion crates/factor-outbound-http/tests/factor_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async fn disallowed_host_fails() -> anyhow::Result<()> {
http: OutboundHttpFactor,
};
let env = test_env();
let mut state = env.build_instance_state(factors).await?;
let mut state = env.build_instance_state(factors, ()).await?;
let mut wasi_http = OutboundHttpFactor::get_wasi_http_impl(&mut state).unwrap();

let req = Request::get("https://denied.test").body(Default::default())?;
Expand Down
13 changes: 8 additions & 5 deletions crates/factor-outbound-networking/tests/factor_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async fn configures_wasi_socket_addr_check() -> anyhow::Result<()> {
};

let env = test_env();
let mut state = env.build_instance_state(factors).await?;
let mut state = env.build_instance_state(factors, ()).await?;
let mut wasi = WasiFactor::get_wasi_impl(&mut state).unwrap();

let network_resource = wasi.instance_network()?;
Expand Down Expand Up @@ -62,10 +62,13 @@ async fn wasi_factor_is_optional() -> anyhow::Result<()> {
networking: OutboundNetworkingFactor,
}
TestEnvironment::default()
.build_instance_state(WithoutWasi {
variables: VariablesFactor::default(),
networking: OutboundNetworkingFactor,
})
.build_instance_state(
WithoutWasi {
variables: VariablesFactor::default(),
networking: OutboundNetworkingFactor,
},
(),
)
.await?;
Ok(())
}
10 changes: 5 additions & 5 deletions crates/factor-outbound-pg/tests/factor_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn factors() -> Result<TestFactors> {
networking: OutboundNetworkingFactor,
pg: OutboundPgFactor::<MockClient>::new(),
};
f.variables.add_provider_type(StaticVariables)?;
f.variables.add_provider_resolver(StaticVariables)?;
Ok(f)
}

Expand All @@ -43,7 +43,7 @@ async fn disallowed_host_fails() -> anyhow::Result<()> {
[component.test-component]
source = "does-not-exist.wasm"
});
let mut state = env.build_instance_state(factors).await?;
let mut state = env.build_instance_state(factors, ()).await?;

let res = state
.pg
Expand All @@ -61,7 +61,7 @@ async fn disallowed_host_fails() -> anyhow::Result<()> {
async fn allowed_host_succeeds() -> anyhow::Result<()> {
let factors = factors()?;
let env = test_env();
let mut state = env.build_instance_state(factors).await?;
let mut state = env.build_instance_state(factors, ()).await?;

let res = state
.pg
Expand All @@ -78,7 +78,7 @@ async fn allowed_host_succeeds() -> anyhow::Result<()> {
async fn exercise_execute() -> anyhow::Result<()> {
let factors = factors()?;
let env = test_env();
let mut state = env.build_instance_state(factors).await?;
let mut state = env.build_instance_state(factors, ()).await?;

let connection = state
.pg
Expand All @@ -97,7 +97,7 @@ async fn exercise_execute() -> anyhow::Result<()> {
async fn exercise_query() -> anyhow::Result<()> {
let factors = factors()?;
let env = test_env();
let mut state = env.build_instance_state(factors).await?;
let mut state = env.build_instance_state(factors, ()).await?;

let connection = state
.pg
Expand Down
2 changes: 1 addition & 1 deletion crates/factor-outbound-redis/tests/factor_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async fn no_outbound_hosts_fails() -> anyhow::Result<()> {
},
..Default::default()
};
let mut state = env.build_instance_state(factors).await?;
let mut state = env.build_instance_state(factors, ()).await?;
let connection = state
.redis
.open("redis://redis.test:8080".to_string())
Expand Down
2 changes: 1 addition & 1 deletion crates/factor-wasi/tests/factor_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async fn environment_works() -> anyhow::Result<()> {
wasi: WasiFactor::new(DummyFilesMounter),
};
let env = test_env();
let mut state = env.build_instance_state(factors).await?;
let mut state = env.build_instance_state(factors, ()).await?;
let mut wasi = WasiFactor::get_wasi_impl(&mut state).unwrap();
let val = wasi
.get_environment()?
Expand Down
2 changes: 1 addition & 1 deletion crates/factors/tests/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use spin_factor_outbound_http::OutboundHttpFactor;
use spin_factor_outbound_networking::OutboundNetworkingFactor;
use spin_factor_variables::{spin_cli::StaticVariables, VariablesFactor};
use spin_factor_wasi::{DummyFilesMounter, WasiFactor};
use spin_factors::{FactorRuntimeConfig, RuntimeConfigSource, RuntimeFactors};
use spin_factors::RuntimeFactors;
use wasmtime_wasi_http::WasiHttpView;

#[derive(RuntimeFactors)]
Expand Down

0 comments on commit 4a3daec

Please sign in to comment.