From 90a2dcd9aff215a7cbea085d64aae54cd3bbb60c Mon Sep 17 00:00:00 2001 From: tpmccallum Date: Tue, 7 May 2024 13:19:03 +1000 Subject: [PATCH 01/11] Adding spin test documentation Signed-off-by: tpmccallum --- content/spin/v2/testing-apps.md | 99 +++++++++++++++++++++++++++++++++ templates/spin_sidebar_v2.hbs | 4 ++ 2 files changed, 103 insertions(+) create mode 100644 content/spin/v2/testing-apps.md diff --git a/content/spin/v2/testing-apps.md b/content/spin/v2/testing-apps.md new file mode 100644 index 000000000..118ecdace --- /dev/null +++ b/content/spin/v2/testing-apps.md @@ -0,0 +1,99 @@ +title = "Testing Applications" +template = "spin_main" +date = "2024-05-05T00:00:01Z" +[extra] +url = "https://github.com/fermyon/developer/blob/main/content/spin/v2/testing-apps.md" + +--- + +The `spin-test` plugin allows you to run tests, written in WebAssembly, against a Spin application (where all Spin and WASI APIs are configurable mocks). + +To use `spin-test` you write test scenarios for your app in any language, with WebAssembly component support, and mock out all interactions your app has with the outside world without requiring any code changes to the app itself. That means the code you test in development is the same code that runs in production. + +## Prerequisites + +Spin test requires Spin 2.5 or newer. Please [install](./install.md) or [upgrade](./upgrade.md) Spin to begin. + +## Installing the Plugin + +To run `spin-test` , you’ll first need to install the canary release of the plugin. As `spin-test` matures, we’ll be making stable releases: + +```bash +spin plugin install -u https://github.com/fermyon/spin-test/releases/download/canary/spin-test.json +``` + +This will install the plugin which can be invoked with `spin test`: + +## Writing a Test + +Next, you'll need a test that `spin-test` can run compiled to a WebAssembly component. + +There is currently first-class support for Rust, but any language with support for writing WebAssembly components can be used as long as the `fermyon:spin-test/test` world is targeted. You can find the definition of this world [here](https://github.com/fermyon/spin-test/blob/4dcaf79c10fc29a8da2750bdaa383b5869db1715/host-wit/world.wit#L13-L16). + +Here’s an example of a test written in Rust using the [Spin Test Rust SDK](https://github.com/fermyon/spin-test) that tests to ensure that the Spin app responds properly when the key-value store has a certain key already set: + +```rust +use spin_test_sdk::{ + bindings::{fermyon::spin_test_virt, wasi}, + spin_test, +}; + +#[spin_test] +fn cache_hit() { + let user_json = r#"{"id":123,"name":"Ryan"}"#; + + // Configure the app's 'cache' key-value store + let key_value = spin_test_virt::key_value::Store::open("cache"); + // Set a specific key with a specific value + key_value.set("123", user_json.as_bytes()); + + // Make the request against the Spin app + let request = wasi::http::types::OutgoingRequest::new(wasi::http::types::Headers::new()); + request.set_path_with_query(Some("/?user_id=123")).unwrap(); + let response = spin_test_sdk::perform_request(request); + + // Assert the response status and body + assert_eq!(response.status(), 200); + let body = response.body_as_string().unwrap(); + assert_eq!(body, user_json); + + // Assert the key-value store was queried + assert_eq!( + key_value.calls(), + vec![spin_test_virt::key_value::Call::Get("123".to_owned())] + ); +} +``` + +The test above will run inside of WebAssembly. The calls to the key-value store and the Spin app itself never leave the WebAssembly sandbox. This means your tests are quick and reproducible as you don’t need to rely on running an actual web server, and you don’t need to ensure any of your app’s dependencies are running. Everything your app interacts with is mocked for you. + +## Configure Spin Test + +Before we can run the test, we'll need to tell `spin-test` where our test lives and how to build it. We do this from inside our app’s manifest (the `spin.toml` file). Let's imagine our app has a component named "my-component" that we want to test. In the manifest we can add the following configuration: + +```toml +[component.my-component.tool.spin-test] +# A relative path to where the built test component binary will live. +source = "my-test/target/wasm32-wasi/release/test.wasm" +# A command for building the target component. +build = "cargo component build --release" +# The directory where the `build` command should be run. +dir = "my-test" +``` + +## Running the Test + +Finally, we're ready for our test to be run. We can do this simply by invoking `spin-test` from the directory where our Spin application lives: + +```bash +$ spin-test + +running 1 test +test cache-hit ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.46s +``` + +## Next Steps + +`spin-test` is still in the early days of development, so you’re likely to run into things that don’t quite work yet. We’d love to hear about your experience so we can prioritize which features and bugs to fix first. We’re excited about the future of testing powered by WebAssembly components, and we look forward to hearing about your experiences as we continue the development of `spin-test`. \ No newline at end of file diff --git a/templates/spin_sidebar_v2.hbs b/templates/spin_sidebar_v2.hbs index cd83c57fa..f112390ed 100644 --- a/templates/spin_sidebar_v2.hbs +++ b/templates/spin_sidebar_v2.hbs @@ -187,6 +187,10 @@ class="active" {{/if}} href="{{site.info.base_url}}/spin/v2/managing-plugins">Managing Plugins +
  • Testing Applications +
  • From 48b1a78eebb32d69cfabe2adf00e3ac14938f6aa Mon Sep 17 00:00:00 2001 From: Timothy McCallum Date: Wed, 8 May 2024 08:45:45 +1000 Subject: [PATCH 02/11] Update content/spin/v2/testing-apps.md Signed-off-by: tpmccallum tim.mccallum@fermyon.com Co-authored-by: itowlson Signed-off-by: Timothy McCallum --- content/spin/v2/testing-apps.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/content/spin/v2/testing-apps.md b/content/spin/v2/testing-apps.md index 118ecdace..34566a6c7 100644 --- a/content/spin/v2/testing-apps.md +++ b/content/spin/v2/testing-apps.md @@ -67,7 +67,8 @@ fn cache_hit() { The test above will run inside of WebAssembly. The calls to the key-value store and the Spin app itself never leave the WebAssembly sandbox. This means your tests are quick and reproducible as you don’t need to rely on running an actual web server, and you don’t need to ensure any of your app’s dependencies are running. Everything your app interacts with is mocked for you. -## Configure Spin Test + +## Configure `spin-test` Before we can run the test, we'll need to tell `spin-test` where our test lives and how to build it. We do this from inside our app’s manifest (the `spin.toml` file). Let's imagine our app has a component named "my-component" that we want to test. In the manifest we can add the following configuration: From 6e4cef760354a35e2a45b1e1d132011667b66d28 Mon Sep 17 00:00:00 2001 From: Timothy McCallum Date: Wed, 8 May 2024 08:46:18 +1000 Subject: [PATCH 03/11] Update content/spin/v2/testing-apps.md Signed-off-by: tpmccallum tim.mccallum@fermyon.com Co-authored-by: itowlson Signed-off-by: Timothy McCallum --- content/spin/v2/testing-apps.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/spin/v2/testing-apps.md b/content/spin/v2/testing-apps.md index 34566a6c7..e9a2bc172 100644 --- a/content/spin/v2/testing-apps.md +++ b/content/spin/v2/testing-apps.md @@ -70,7 +70,7 @@ The test above will run inside of WebAssembly. The calls to the key-value store ## Configure `spin-test` -Before we can run the test, we'll need to tell `spin-test` where our test lives and how to build it. We do this from inside our app’s manifest (the `spin.toml` file). Let's imagine our app has a component named "my-component" that we want to test. In the manifest we can add the following configuration: +Before you can run the test, you'll need to tell `spin-test` where your test lives and how to build it. You do this from inside our app’s manifest (the `spin.toml` file). Let's imagine your app has a component named "my-component" that you want to test. In the manifest, you would add the following configuration: ```toml [component.my-component.tool.spin-test] From a21079e026d924f45637cf89b14e032845649101 Mon Sep 17 00:00:00 2001 From: Timothy McCallum Date: Wed, 8 May 2024 08:46:39 +1000 Subject: [PATCH 04/11] Update content/spin/v2/testing-apps.md Signed-off-by: tpmccallum tim.mccallum@fermyon.com Co-authored-by: itowlson Signed-off-by: Timothy McCallum --- content/spin/v2/testing-apps.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/spin/v2/testing-apps.md b/content/spin/v2/testing-apps.md index e9a2bc172..1d5877ff8 100644 --- a/content/spin/v2/testing-apps.md +++ b/content/spin/v2/testing-apps.md @@ -76,7 +76,7 @@ Before you can run the test, you'll need to tell `spin-test` where your test liv [component.my-component.tool.spin-test] # A relative path to where the built test component binary will live. source = "my-test/target/wasm32-wasi/release/test.wasm" -# A command for building the target component. +# A command for building the test component. build = "cargo component build --release" # The directory where the `build` command should be run. dir = "my-test" From f0f268de50bf6e7e40a3586c0c66e4cebf7200d0 Mon Sep 17 00:00:00 2001 From: Timothy McCallum Date: Wed, 8 May 2024 08:47:04 +1000 Subject: [PATCH 05/11] Update content/spin/v2/testing-apps.md Signed-off-by: tpmccallum tim.mccallum@fermyon.com Co-authored-by: itowlson Signed-off-by: Timothy McCallum --- content/spin/v2/testing-apps.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/spin/v2/testing-apps.md b/content/spin/v2/testing-apps.md index 1d5877ff8..49c17927d 100644 --- a/content/spin/v2/testing-apps.md +++ b/content/spin/v2/testing-apps.md @@ -84,7 +84,7 @@ dir = "my-test" ## Running the Test -Finally, we're ready for our test to be run. We can do this simply by invoking `spin-test` from the directory where our Spin application lives: +Finally, we're ready for our test to be run. We can do this by invoking `spin-test` from the directory where our Spin application lives: ```bash $ spin-test From 0dc04716d5f6a4991046ad4f8c9ce05de79551df Mon Sep 17 00:00:00 2001 From: tpmccallum Date: Wed, 8 May 2024 16:05:03 +1000 Subject: [PATCH 06/11] Adding example of creating component to test Signed-off-by: tpmccallum --- content/spin/v2/testing-apps.md | 159 +++++++++++++++++++++++++------- 1 file changed, 127 insertions(+), 32 deletions(-) diff --git a/content/spin/v2/testing-apps.md b/content/spin/v2/testing-apps.md index 49c17927d..f1b3bf209 100644 --- a/content/spin/v2/testing-apps.md +++ b/content/spin/v2/testing-apps.md @@ -10,9 +10,11 @@ The `spin-test` plugin allows you to run tests, written in WebAssembly, against To use `spin-test` you write test scenarios for your app in any language, with WebAssembly component support, and mock out all interactions your app has with the outside world without requiring any code changes to the app itself. That means the code you test in development is the same code that runs in production. +> Note: `spin-test` is still under active development and so the details here may have changed since this post was first published. Check [the spin-test repo](https://github.com/fermyon/spin-test) for the latest information on installation and usage. + ## Prerequisites -Spin test requires Spin 2.5 or newer. Please [install](./install.md) or [upgrade](./upgrade.md) Spin to begin. +The example below uses the [Rust programming language](https://www.rust-lang.org/) and [cargo components](https://github.com/bytecodealliance/cargo-component)(a cargo subcommand for building WebAssembly components). ## Installing the Plugin @@ -22,71 +24,164 @@ To run `spin-test` , you’ll first need to install the canary release of the pl spin plugin install -u https://github.com/fermyon/spin-test/releases/download/canary/spin-test.json ``` -This will install the plugin which can be invoked with `spin test`: +This will install the plugin which can be invoked with `spin test`. + +## Creating App and Component + +First, create an empty Spin app, change into that app folder and then add a component inside it: + + + +```bash +$ spin new -t http-empty my-component --accept-defaults +$ cd my-component/ +$ spin add -t http-rust my-component --accept-defaults +``` + +## Creating Test Suite + +We use `cargo new` to create a test suite, and then change into that directory: + + + +```bash +$ cargo new tests --lib +$ cd tests +``` + +From within that test suite, we then add the spin-test SDK reference: + + + +```bash +$ cargo add spin-test-sdk --git https://github.com/fermyon/spin-test +``` + +Then, we open the `Cargo.toml` file and edit to add the crate-type of `cdylib`: + + + +```toml +[lib] +crate-type = ["cdylib"] +``` + +The `my-component/tests/Cargo.toml` file will look like this after editing: + +```toml +[package] +name = "tests" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["cdylib"] + +[dependencies] +spin-test-sdk = { git = "https://github.com/fermyon/spin-test", version = "0.1.0" } +``` ## Writing a Test -Next, you'll need a test that `spin-test` can run compiled to a WebAssembly component. +Next, create a test test that `spin-test` can run as a compiled WebAssembly component. There is currently first-class support for Rust, but any language with support for writing WebAssembly components can be used as long as the `fermyon:spin-test/test` world is targeted. You can find the definition of this world [here](https://github.com/fermyon/spin-test/blob/4dcaf79c10fc29a8da2750bdaa383b5869db1715/host-wit/world.wit#L13-L16). -Here’s an example of a test written in Rust using the [Spin Test Rust SDK](https://github.com/fermyon/spin-test) that tests to ensure that the Spin app responds properly when the key-value store has a certain key already set: +Here’s an example of a test written in Rust using the [Spin Test Rust SDK](https://github.com/fermyon/spin-test/tree/main/crates/spin-test-sdk) that tests to ensure that the Spin app responds properly when the key-value store has a certain key already set. + +Open the `my-component/my-component/src/lib.rs` file and fill it with the following content: ```rust use spin_test_sdk::{ - bindings::{fermyon::spin_test_virt, wasi}, + bindings::{ + // fermyon::spin_test_virt::{http_handler, key_value}, + wasi::http, + }, spin_test, }; #[spin_test] -fn cache_hit() { - let user_json = r#"{"id":123,"name":"Ryan"}"#; - - // Configure the app's 'cache' key-value store - let key_value = spin_test_virt::key_value::Store::open("cache"); - // Set a specific key with a specific value - key_value.set("123", user_json.as_bytes()); +fn it_works() { + make_request(); +} - // Make the request against the Spin app - let request = wasi::http::types::OutgoingRequest::new(wasi::http::types::Headers::new()); +fn make_request() { + // Perform the request + let request = http::types::OutgoingRequest::new(http::types::Headers::new()); request.set_path_with_query(Some("/?user_id=123")).unwrap(); let response = spin_test_sdk::perform_request(request); - // Assert the response status and body + // Assert response status and body assert_eq!(response.status(), 200); - let body = response.body_as_string().unwrap(); - assert_eq!(body, user_json); - - // Assert the key-value store was queried - assert_eq!( - key_value.calls(), - vec![spin_test_virt::key_value::Call::Get("123".to_owned())] - ); } ``` -The test above will run inside of WebAssembly. The calls to the key-value store and the Spin app itself never leave the WebAssembly sandbox. This means your tests are quick and reproducible as you don’t need to rely on running an actual web server, and you don’t need to ensure any of your app’s dependencies are running. Everything your app interacts with is mocked for you. +The following points are intended to unpack the above example for your understanding: + +- Each function marked with `#[spin_test]` will be run as a separate test. +- Each test can perform any setup to their environment by using the APIs available in `spin_test_sdk::bindings::fermyon::spin_test_virt`. +- Requests are made to the Spin application using the `spin_test_sdk::perform_request` function. +- After requests are made, you can use the APIs in `spin_test_sdk::bindings::fermyon::spin_test_virt` to check how the request has changed the state of various resources (such as the key/value store) and make assertions that things changed in the way you expected. + +The test above will run inside of WebAssembly. Calls, such as Key Value storage and retrieval, never actually leave the WebAssembly sandbox. This means your tests are quick and reproducible as you don’t need to rely on running an actual web server, and you don’t need to ensure any of your app’s dependencies are running. Everything your app interacts with is mocked for you. ## Configure `spin-test` -Before you can run the test, you'll need to tell `spin-test` where your test lives and how to build it. You do this from inside our app’s manifest (the `spin.toml` file). Let's imagine your app has a component named "my-component" that you want to test. In the manifest, you would add the following configuration: +Before you can run the test, you'll need to tell `spin-test` where your test lives and how to build it. You do this from inside our app’s manifest (the `spin.toml` file). We change back up into our application's root directory: + + + +```bash +$ cd .. +``` + +Then we edit the application's manifest (the `spin.toml` file) as shown below: + + ```toml [component.my-component.tool.spin-test] -# A relative path to where the built test component binary will live. -source = "my-test/target/wasm32-wasi/release/test.wasm" -# A command for building the test component. +source = "tests/target/wasm32-wasi/release/tests.wasm" +build = "cargo component build --release" +dir = "tests" +``` + +The whole file will look like the following: + +```toml +spin_manifest_version = 2 + +[application] +name = "my-component" +version = "0.1.0" +authors = ["tpmccallum "] +description = "" + +[[trigger.http]] +route = "/..." +component = "my-component" + +[component.my-component] +source = "my-component/target/wasm32-wasi/release/my_component.wasm" +allowed_outbound_hosts = [] +[component.my-component.build] +command = "cargo build --target wasm32-wasi --release" +workdir = "my-component" +watch = ["src/**/*.rs", "Cargo.toml"] + +[component.my-component.tool.spin-test] +source = "tests/target/wasm32-wasi/release/tests.wasm" build = "cargo component build --release" -# The directory where the `build` command should be run. -dir = "my-test" +dir = "tests" ``` -## Running the Test +## Building and Running the Test Finally, we're ready for our test to be run. We can do this by invoking `spin-test` from the directory where our Spin application lives: ```bash +$ spin build $ spin-test running 1 test @@ -97,4 +192,4 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; fini ## Next Steps -`spin-test` is still in the early days of development, so you’re likely to run into things that don’t quite work yet. We’d love to hear about your experience so we can prioritize which features and bugs to fix first. We’re excited about the future of testing powered by WebAssembly components, and we look forward to hearing about your experiences as we continue the development of `spin-test`. \ No newline at end of file +`spin-test` is still in the early days of development, so you’re likely to run into things that don’t quite work yet. We’d love to hear about your experience so we can prioritize which features and bugs to fix first. We’re excited about the future potential of using WebAssembly components for testing, and we look forward to hearing about your experiences as we continue the development of `spin-test`. \ No newline at end of file From 25d58ec3eceac833cbb646969531e5018f3bf600 Mon Sep 17 00:00:00 2001 From: tpmccallum Date: Wed, 8 May 2024 16:14:29 +1000 Subject: [PATCH 07/11] Adding example of creating component to test Signed-off-by: tpmccallum --- content/spin/v2/testing-apps.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/content/spin/v2/testing-apps.md b/content/spin/v2/testing-apps.md index f1b3bf209..dca26c94a 100644 --- a/content/spin/v2/testing-apps.md +++ b/content/spin/v2/testing-apps.md @@ -38,13 +38,23 @@ $ cd my-component/ $ spin add -t http-rust my-component --accept-defaults ``` +We then go into the component directory and add the spin-test SDK: + + + +```bash +cd my-component +cargo add spin-test-sdk --git https://github.com/fermyon/spin-test +``` + ## Creating Test Suite -We use `cargo new` to create a test suite, and then change into that directory: +We, change back into the app's root directory and use `cargo new` to create a test suite, and then change into that directory: ```bash +$ cd .. $ cargo new tests --lib $ cd tests ``` From 90fd3392e002ab8f38d8eef6de5559b5138c8702 Mon Sep 17 00:00:00 2001 From: tpmccallum Date: Wed, 8 May 2024 16:15:58 +1000 Subject: [PATCH 08/11] Adding example of creating component to test Signed-off-by: tpmccallum --- content/spin/v2/testing-apps.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/spin/v2/testing-apps.md b/content/spin/v2/testing-apps.md index dca26c94a..7078efb1c 100644 --- a/content/spin/v2/testing-apps.md +++ b/content/spin/v2/testing-apps.md @@ -47,7 +47,7 @@ cd my-component cargo add spin-test-sdk --git https://github.com/fermyon/spin-test ``` -## Creating Test Suite +## Creating a Test Suite We, change back into the app's root directory and use `cargo new` to create a test suite, and then change into that directory: From 81e8c3644cfb7db5ad57d750d3bdc207c4cfff0c Mon Sep 17 00:00:00 2001 From: tpmccallum Date: Wed, 8 May 2024 16:35:43 +1000 Subject: [PATCH 09/11] Update and test Signed-off-by: tpmccallum --- content/spin/v2/testing-apps.md | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/content/spin/v2/testing-apps.md b/content/spin/v2/testing-apps.md index 7078efb1c..d4217589a 100644 --- a/content/spin/v2/testing-apps.md +++ b/content/spin/v2/testing-apps.md @@ -38,15 +38,6 @@ $ cd my-component/ $ spin add -t http-rust my-component --accept-defaults ``` -We then go into the component directory and add the spin-test SDK: - - - -```bash -cd my-component -cargo add spin-test-sdk --git https://github.com/fermyon/spin-test -``` - ## Creating a Test Suite We, change back into the app's root directory and use `cargo new` to create a test suite, and then change into that directory: @@ -54,7 +45,6 @@ We, change back into the app's root directory and use `cargo new` to create a te ```bash -$ cd .. $ cargo new tests --lib $ cd tests ``` @@ -99,7 +89,7 @@ There is currently first-class support for Rust, but any language with support f Here’s an example of a test written in Rust using the [Spin Test Rust SDK](https://github.com/fermyon/spin-test/tree/main/crates/spin-test-sdk) that tests to ensure that the Spin app responds properly when the key-value store has a certain key already set. -Open the `my-component/my-component/src/lib.rs` file and fill it with the following content: +Open the `my-component/tests/src/lib.rs` file and fill it with the following content: ```rust use spin_test_sdk::{ From de1bf90520d9aa71a1f0f9846bc5563525adce83 Mon Sep 17 00:00:00 2001 From: tpmccallum Date: Wed, 8 May 2024 16:36:25 +1000 Subject: [PATCH 10/11] Show successful test output Signed-off-by: tpmccallum --- content/spin/v2/testing-apps.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/content/spin/v2/testing-apps.md b/content/spin/v2/testing-apps.md index d4217589a..084ddfaa6 100644 --- a/content/spin/v2/testing-apps.md +++ b/content/spin/v2/testing-apps.md @@ -185,9 +185,10 @@ $ spin build $ spin-test running 1 test -test cache-hit ... ok +Handling request to Some(HeaderValue { inner: String("http://localhost/?user_id=123") }) +test it-works ... ok -test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.46s +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.68s ``` ## Next Steps From 01b80a9c17f4e45e75c9b8f61a591df15be1d09f Mon Sep 17 00:00:00 2001 From: tpmccallum Date: Wed, 8 May 2024 20:57:41 +1000 Subject: [PATCH 11/11] Last updates, ready for review and merge Signed-off-by: tpmccallum --- content/spin/v2/testing-apps.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/content/spin/v2/testing-apps.md b/content/spin/v2/testing-apps.md index 084ddfaa6..ef2afa02f 100644 --- a/content/spin/v2/testing-apps.md +++ b/content/spin/v2/testing-apps.md @@ -40,7 +40,7 @@ $ spin add -t http-rust my-component --accept-defaults ## Creating a Test Suite -We, change back into the app's root directory and use `cargo new` to create a test suite, and then change into that directory: +We use `cargo new` to create a test suite, and then change into that `tests` directory: @@ -57,7 +57,7 @@ From within that test suite, we then add the spin-test SDK reference: $ cargo add spin-test-sdk --git https://github.com/fermyon/spin-test ``` -Then, we open the `Cargo.toml` file and edit to add the crate-type of `cdylib`: +Then, we open the `Cargo.toml` file from within in the `tests` directory and edit to add the `crate-type` of `cdylib`: @@ -83,7 +83,7 @@ spin-test-sdk = { git = "https://github.com/fermyon/spin-test", version = "0.1.0 ## Writing a Test -Next, create a test test that `spin-test` can run as a compiled WebAssembly component. +Next, create a test that `spin-test` can run as a compiled WebAssembly component. There is currently first-class support for Rust, but any language with support for writing WebAssembly components can be used as long as the `fermyon:spin-test/test` world is targeted. You can find the definition of this world [here](https://github.com/fermyon/spin-test/blob/4dcaf79c10fc29a8da2750bdaa383b5869db1715/host-wit/world.wit#L13-L16). @@ -155,7 +155,7 @@ spin_manifest_version = 2 [application] name = "my-component" version = "0.1.0" -authors = ["tpmccallum "] +authors = ["Fermyon Engineering "] description = "" [[trigger.http]]