31 releases

new 0.14.0 Oct 23, 2024
0.12.0 Sep 30, 2024
0.11.0 Sep 20, 2023
0.10.0 Jul 20, 2023
0.1.8 Oct 24, 2021

#181 in WebAssembly

Download history 22/week @ 2024-06-30 25/week @ 2024-07-14 7/week @ 2024-07-21 49/week @ 2024-07-28 57/week @ 2024-09-22 223/week @ 2024-09-29 159/week @ 2024-10-06 13/week @ 2024-10-13

452 downloads per month
Used in 2 crates

Apache-2.0

2MB
12K SLoC

This crate contains utilities for testing wasmCloud, a universal application platform powered by WebAssembly.

You can use this crate to start the wasmCloud host, test both wasmCloud components and [capability providers][docs-provider]s, and more.

Quickstart

When building integration tests, you can start the wasmCloud host without wash and directly from Rust code to test it:

use wasmcloud_test_util::{assert_config_put, assert_scale_component, WasmCloudTestHost};
use wasmcloud_test_util::control_interface::ClientBuilder;


// Build a wasmCloud host (assuming you have a local NATS server running)
let nats_url = "nats://localhost:4222";
let lattice = "default";
let host = WasmCloudTestHost::start(nats_url, lattice).await?;

// Once you have a host (AKA a single-member wasmCloud lattice), you'll want a NATS client
// which you can use to control the host and the lattice:
let nats_client = async_nats::connect(nats_url).await?;
let ctl_client = ClientBuilder::new(nats_client)
    .lattice(host.lattice_name().to_string())
    .build();

// Now that you have a control client, you can use the `assert_*` functions to perform actions on your host:
assert_config_put(
    &ctl_client,
    "test-config",
    [("EXAMPLE_KEY".to_string(), "EXAMPLE_VALUE".to_string())],
)
.await?;

assert_scale_component(
    &ctl_client,
    &host.host_key(),
    "ghcr.io/wasmcloud/components/http-jsonify-rust:0.1.1",
    "example-component",
    None,
    1,
    Vec::new(),
)
.await?;

// ...

Ok(())

You can find examples of this crate in use in the wasmCloud repository tests folder.

Dependencies

~86MB
~1.5M SLoC