switch test wasm plugin to version that does not require WASI

This commit is contained in:
Joel Wetzell
2026-03-17 12:06:12 -05:00
parent 97c1975c7f
commit b17e0489a5
2 changed files with 12 additions and 17 deletions

Binary file not shown.

View File

@@ -1,7 +1,7 @@
package processor_test package processor_test
import ( import (
"slices" "reflect"
"testing" "testing"
"github.com/jwetzell/showbridge-go/internal/common" "github.com/jwetzell/showbridge-go/internal/common"
@@ -34,15 +34,14 @@ func TestScriptWASMFromRegistry(t *testing.T) {
func TestGoodScriptWASM(t *testing.T) { func TestGoodScriptWASM(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
payload []byte payload any
params map[string]any params map[string]any
expected []byte expected any
}{ }{
{ {
name: "string input, default process function with wasi", name: "string input, default process function with wasi",
params: map[string]any{ params: map[string]any{
"path": "good.wasm", "path": "good.wasm",
"enableWasi": true,
}, },
payload: []byte("hello"), payload: []byte("hello"),
expected: []byte("Processed: hello"), expected: []byte("Processed: hello"),
@@ -50,9 +49,8 @@ func TestGoodScriptWASM(t *testing.T) {
{ {
name: "string input, specified function with wasi", name: "string input, specified function with wasi",
params: map[string]any{ params: map[string]any{
"path": "good.wasm", "path": "good.wasm",
"enableWasi": true, "function": "greet",
"function": "greet",
}, },
payload: []byte("world"), payload: []byte("world"),
expected: []byte("Hello, world"), expected: []byte("Hello, world"),
@@ -86,7 +84,7 @@ func TestGoodScriptWASM(t *testing.T) {
t.Fatalf("script.wasm returned a %T payload: %+v", got, got) t.Fatalf("script.wasm returned a %T payload: %+v", got, got)
} }
if !slices.Equal(gotBytes, test.expected) { if !reflect.DeepEqual(gotBytes, test.expected) {
t.Fatalf("script.wasm got %+v, expected %+v", gotBytes, test.expected) t.Fatalf("script.wasm got %+v, expected %+v", gotBytes, test.expected)
} }
}) })
@@ -117,9 +115,8 @@ func TestBadScriptWASM(t *testing.T) {
{ {
name: "non-string function", name: "non-string function",
params: map[string]any{ params: map[string]any{
"path": "good.wasm", "path": "good.wasm",
"enableWasi": true, "function": 12345,
"function": 12345,
}, },
payload: []byte("hello"), payload: []byte("hello"),
errorString: "script.wasm function error: not a string", errorString: "script.wasm function error: not a string",
@@ -136,8 +133,7 @@ func TestBadScriptWASM(t *testing.T) {
{ {
name: "non-byte slice input", name: "non-byte slice input",
params: map[string]any{ params: map[string]any{
"path": "good.wasm", "path": "good.wasm",
"enableWasi": true,
}, },
payload: "hello", payload: "hello",
errorString: "script.wasm can only process a byte array", errorString: "script.wasm can only process a byte array",
@@ -145,9 +141,8 @@ func TestBadScriptWASM(t *testing.T) {
{ {
name: "function not found in module", name: "function not found in module",
params: map[string]any{ params: map[string]any{
"path": "good.wasm", "path": "good.wasm",
"enableWasi": true, "function": "asdf",
"function": "asdf",
}, },
payload: []byte("hello"), payload: []byte("hello"),
errorString: "unknown function: asdf", errorString: "unknown function: asdf",