-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2274 from lann/moar-tests
tests: Migrate wagi test to integration test suite
- Loading branch information
Showing
10 changed files
with
92 additions
and
70 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
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,4 @@ | ||
[package] | ||
name = "integration_wagi" | ||
version = "0.1.0" | ||
edition = "2021" |
21 changes: 21 additions & 0 deletions
21
tests/test-components/components/integration-wagi/src/main.rs
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,21 @@ | ||
use std::error::Error; | ||
|
||
fn main() -> Result<(), Box<dyn Error>> { | ||
let body = match std::env::var("PATH_INFO")?.as_str() { | ||
"/hello" => "I'm a teapot".into(), | ||
"/echo" => std::io::read_to_string(std::io::stdin())?, | ||
"/args" => format!("{:?}", std::env::args().collect::<Vec<_>>()), | ||
"/env" => { | ||
let key = std::env::args().nth(1).unwrap_or_default(); | ||
std::env::var(key)? | ||
} | ||
other => { | ||
println!("Content-Type: text/plain"); | ||
println!("Status: 404\n\n"); | ||
println!("Not Found (PATH_INFO={other:?})"); | ||
return Ok(()); | ||
} | ||
}; | ||
print!("Content-Type: text/plain\n\n{body}"); | ||
Ok(()) | ||
} |
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,18 @@ | ||
spin_manifest_version = 2 | ||
|
||
[application] | ||
authors = ["Fermyon Engineering <[email protected]>"] | ||
description = "Test using WAGI HTTP." | ||
name = "wagi-http" | ||
version = "1.0.0" | ||
|
||
[application.trigger.http] | ||
base = "/base" | ||
|
||
[[trigger.http]] | ||
route = "/..." | ||
component = "wagi-http" | ||
executor = { type = "wagi" } | ||
|
||
[component.wagi-http] | ||
source = "%{source=integration-wagi}" |