wasi-module-sdk-go/examples/hello_world_go/main_test.go
2023-05-18 18:21:44 +02:00

32 lines
754 B
Go

package main_test
import (
sdk "code.icb4dc0.de/buildr/wasi-module-sdk-go"
"code.icb4dc0.de/buildr/wasi-module-sdk-go/integration"
"context"
_ "embed"
"golang.org/x/exp/slog"
"testing"
)
//go:embed hello_world.wasm
var payload []byte
func TestModule(t *testing.T) {
h := integration.NewHost(
slog.New(slog.NewTextHandler(integration.NewTestWriter(t))),
integration.WithState(integration.StateKey(sdk.CategoryTask, "test", "hello"), []byte("world")),
)
s := integration.TestSpec{
ModuleCategory: sdk.CategoryTask,
ModuleType: "hello_world",
ModuleName: "test",
RawTaskSpec: []byte(`{"Name": "Ted"}`),
}
if err := h.Run(context.Background(), payload, s); err != nil {
t.Errorf("Failed to run module: %v", err)
}
}