Files
Reims-Go/internal/plugin/channels_test.go
T

39 lines
1.3 KiB
Go

package plugin
import "testing"
func TestManifestValidatesChannels(t *testing.T) {
base := Manifest{
ID: "vendor.agent",
Version: "1.0.0",
Name: LocalizedText{EnUS: "Agent"},
Entry: Entry{Sidecar: "bin/agent.exe"},
Contributes: Contributes{Channels: []ChannelContribution{
{ID: "mcp", Framing: "jsonl"},
}},
}
if err := ValidateManifest(base, "dev", false); err != nil {
t.Fatalf("valid JSONL channel rejected: %v", err)
}
for _, tc := range []struct {
name string
channels []ChannelContribution
sidecar string
}{
{name: "unknown framing", channels: []ChannelContribution{{ID: "mcp", Framing: "raw"}}, sidecar: "bin/agent.exe"},
{name: "duplicate id", channels: []ChannelContribution{{ID: "mcp", Framing: "jsonl"}, {ID: "mcp", Framing: "jsonl"}}, sidecar: "bin/agent.exe"},
{name: "invalid id", channels: []ChannelContribution{{ID: "MCP", Framing: "jsonl"}}, sidecar: "bin/agent.exe"},
{name: "missing sidecar", channels: []ChannelContribution{{ID: "mcp", Framing: "jsonl"}}},
} {
t.Run(tc.name, func(t *testing.T) {
m := base
m.Entry.Sidecar = tc.sidecar
m.Contributes.Channels = tc.channels
if err := ValidateManifest(m, "dev", false); err == nil {
t.Fatal("invalid channel declaration accepted")
}
})
}
}