2023-05-08 13:21:31 +00:00
|
|
|
package main_test
|
|
|
|
|
|
|
|
import (
|
2023-05-18 16:21:44 +00:00
|
|
|
sdk "code.icb4dc0.de/buildr/wasi-module-sdk-go"
|
|
|
|
"code.icb4dc0.de/buildr/wasi-module-sdk-go/integration"
|
2023-05-08 13:21:31 +00:00
|
|
|
"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)
|
|
|
|
}
|
|
|
|
}
|