32 lines
748 B
Go
32 lines
748 B
Go
|
package main_test
|
||
|
|
||
|
import (
|
||
|
sdk "code.icb4dc0.de/buildr/wasi-module-sdk"
|
||
|
"code.icb4dc0.de/buildr/wasi-module-sdk/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)
|
||
|
}
|
||
|
}
|