MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime-go / TestComponentNew

Function TestComponentNew

component_feat_component_model_test.go:22–48  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

20`
21
22func TestComponentNew(t *testing.T) {
23 helloWasm, err := Wat2Wasm(helloComponent)
24 require.NoError(t, err)
25
26 cases := []struct {
27 name string
28 input []byte
29 wantErr bool
30 }{
31 {"empty", []byte{}, true},
32 {"garbage", []byte{1, 2, 3}, true},
33 {"valid", helloWasm, false},
34 }
35 for _, tc := range cases {
36 t.Run(tc.name, func(t *testing.T) {
37 engine := newComponentEngine()
38 component, err := NewComponent(engine, tc.input)
39 if tc.wantErr {
40 require.Error(t, err)
41 return
42 }
43 require.NoError(t, err)
44 require.NotNil(t, component)
45 component.Close()
46 })
47 }
48}
49
50func TestComponentSerializeRoundTripBytes(t *testing.T) {
51 cases := []struct {

Callers

nothing calls this directly

Calls 5

CloseMethod · 0.95
Wat2WasmFunction · 0.85
newComponentEngineFunction · 0.85
NewComponentFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…