Skip to main content

Writing tests with workflows

Testing#

In order to test this new functionality, we'll update the existing ./workflows/e2e.yaml workflow file to include the new methods we've added (setIpfsData, and getIpfsData).

Add the following case to the e2e.yaml workflow in the ./workflows folder.

./workflows/e2e.yaml
case2:
steps:
- uri: fs/build
method: setIpfsData
input:
options:
address: "$cases.0.data"
data: "Hello from IPFS!"
- uri: fs/build
method: getIpfsData
input:
address: "$cases.0.data"

Once our workflow has been defined, we may want to be able to validate our actual results against our expectations. Workflow validation uses CUE, a flexible and expressive data validation language. CUE must be installed to complete this step.

If you don't want to install anything right now, don't worry! Our results will be easy to verify with manually.

To continue with automated testing, let's add our expected output to a new file in the workflows folder. We will call the file validator.cue.

./workflows/validator.cue
package e2e
case1: {
$0: {
data: 100,
error?: _|_,
}
},
case2: {
$0: {
data: "QmPhAJz5QbidN3LgT2eDiu6Z3nCFs2gYQMbjgEAncrGsis",
error?: _|_,
}
}

With our workflow complete, we'll deploy and test our Wasm wrapper locally in the next section!