Documentation
¶
Overview ¶
Package plugintest is the golden-test harness for WebAssembly plugin authors. It builds a plugin for wasip1 with the Go toolchain, signs it with a fixed test key, runs it through the scanner's own runtime on a fixture folder and compares the facts with a golden file:
var update = flag.Bool("update", false, "rewrite golden files")
func TestGolden(t *testing.T) {
p := plugintest.Load(t, ".", plugintest.Manifest(t, "manifest.json"))
plugintest.Golden(t, "testdata/fixture", "testdata/fixture.golden.json", *update, p)
}
The test key is public and fixed; never trust it outside tests. See https://cernly.dev/how/wasm-plugins/.
Index ¶
- Constants
- func Build(t testing.TB, pkg string) []byte
- func Golden(t testing.TB, dir, golden string, update bool, ps ...plugin.Plugin)
- func Load(t testing.TB, pkg string, m sdk.Manifest, lim ...wasm.Limits) plugin.Plugin
- func Manifest(t testing.TB, file string) sdk.Manifest
- func Scan(t testing.TB, dir string, ps ...plugin.Plugin) []byte
- func Sign(t testing.TB, module []byte, m sdk.Manifest) wasm.Bundle
- func TestKey() ed25519.PrivateKey
- func TestTrust(t testing.TB) *wasm.Trust
- func ValidScan(data []byte) error
Constants ¶
const ( SHA = "0123456789abcdef0123456789abcdef01234567" CommittedAt = "2026-10-14T16:02:11Z" // ModuleHash replaces a wasm plugin's real hash in goldens: the bytes // differ between Go releases, the facts must not. ModuleHash = "0000000000000000000000000000000000000000000000000000000000000000" )
Fixed commit identity for fixture scans outside git.
Variables ¶
This section is empty.
Functions ¶
func Build ¶
Build compiles the Go main package pkg (a path relative to the test's folder, or an import path) for GOOS=wasip1 GOARCH=wasm, once per test process.
func Golden ¶
Golden scans dir with ps and compares with the golden file; update rewrites it. Every plugin must run ok: an error in a fixture is a bug.
func Scan ¶
Scan scans dir with ps and returns the canonical facts file, wasm hashes replaced by ModuleHash.
func TestKey ¶
func TestKey() ed25519.PrivateKey
TestKey is wasm.TestKey: fixed, public, never trusted in production.
Types ¶
This section is empty.