Skip to content
This repository was archived by the owner on Jun 7, 2024. It is now read-only.

Commit f0991c4

Browse files
authored
Merge pull request #5 from wacker-dev/test
Add integration tests
2 parents 06cb2ae + 18eb91d commit f0991c4

35 files changed

+11910
-1
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,12 @@ jobs:
2020
run: cargo fmt --all -- --check
2121
- name: cargo clippy
2222
run: cargo clippy --all-targets --all-features -- -D warnings
23+
- name: Install wasmtime
24+
uses: bytecodealliance/actions/wasmtime/setup@v1
25+
with:
26+
github_token: ${{ secrets.GITHUB_TOKEN }}
27+
version: "v20.0.0"
2328
- name: cargo test
24-
run: cargo test
29+
run: |
30+
cargo install cargo-component@0.11.0
31+
cargo test

tests/main.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
use anyhow::Result;
2+
use std::process::Command;
3+
4+
#[test]
5+
fn main() -> Result<()> {
6+
let status = Command::new("cargo")
7+
.current_dir("tests/program")
8+
.arg("component")
9+
.arg("build")
10+
.arg("--quiet")
11+
.status()?;
12+
assert!(status.success());
13+
14+
let status = Command::new("wasmtime")
15+
.arg("-S")
16+
.arg("http")
17+
.arg("tests/program/target/wasm32-wasi/debug/wasi_http_client_test_program.wasm")
18+
.status()?;
19+
assert!(status.success());
20+
21+
Ok(())
22+
}

tests/program/Cargo.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[package]
2+
name = "wasi-http-client-test-program"
3+
version = "0.0.0"
4+
edition = "2021"
5+
publish = false
6+
7+
[lib]
8+
crate-type = ["cdylib"]
9+
10+
[package.metadata.component]
11+
package = "component:wasi-http-client-test-program"
12+
13+
[package.metadata.component.dependencies]
14+
15+
[package.metadata.component.target.dependencies]
16+
"wasi:cli" = { path = "wit/deps/cli" }
17+
"wasi:io" = { path = "wit/deps/io" }
18+
"wasi:clocks" = { path = "wit/deps/clocks" }
19+
"wasi:filesystem" = { path = "wit/deps/filesystem" }
20+
"wasi:sockets" = { path = "wit/deps/sockets" }
21+
"wasi:random" = { path = "wit/deps/random" }
22+
23+
[dependencies]
24+
wasi-http-client = { path = "../../../wasi-http-client" }
25+
26+
wit-bindgen-rt = { version = "0.24.0", features = ["bitflags"] }

0 commit comments

Comments
 (0)