feat: publish sanitized custom.97 source
This commit is contained in:
1022 files changed
+69903
-19207
No files matched your search
@@ -589,6 +589,7 @@ func TestRegistryValidatesChannelTypes(t *testing.T) {
|
||||
{name: "zero rejected", channelTypes: []int{0}, wantErr: "positive channel types"},
|
||||
{name: "negative rejected", channelTypes: []int{-1}, wantErr: "positive channel types"},
|
||||
{name: "task plugin type rejected", channelTypes: []int{constant.ChannelTypeTaskPlugin}, wantErr: "task plugin channel type"},
|
||||
{name: "new api type rejected", channelTypes: []int{constant.ChannelTypeNewAPI}, wantErr: "New API channel type"},
|
||||
{name: "duplicates rejected", channelTypes: []int{1, 1}, wantErr: "must be unique"},
|
||||
} {
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
@@ -1127,6 +1128,17 @@ usageProfiles: [
|
||||
assert.Empty(t, schema)
|
||||
assert.Nil(t, examples)
|
||||
|
||||
// A channel mapping may send a declared model to an undeclared endpoint ID:
|
||||
// the first profiled candidate wins, otherwise the defaults apply.
|
||||
schema, examples = plugin.Meta.UsageForModels("ep-endpoint", "image")
|
||||
assert.Equal(t, plugin.Meta.UsageProfiles[0].Schema, schema)
|
||||
assert.Nil(t, examples)
|
||||
schema, _ = plugin.Meta.UsageForModels("video", "image")
|
||||
assert.Equal(t, plugin.Meta.UsageProfiles[1].Schema, schema)
|
||||
schema, examples = plugin.Meta.UsageForModels("ep-endpoint", "default")
|
||||
assert.Equal(t, plugin.Meta.UsageSchema, schema)
|
||||
assert.Equal(t, plugin.Meta.UsageExamples, examples)
|
||||
|
||||
snapshot := registry.Snapshot()
|
||||
require.Len(t, snapshot.Override, 1)
|
||||
profile := &snapshot.Override[0].UsageProfiles[1]
|
||||
@@ -1197,6 +1209,33 @@ usageProfiles: [{models:["image"], schema:{tokens:{type:"number", unit:"token"}}
|
||||
require.ErrorContains(t, ValidateV1Meta(plugin.Meta), "schema must be an object")
|
||||
}
|
||||
|
||||
func TestUpstreamsManifestContract(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name, metadata string
|
||||
valid, newAPI bool
|
||||
}{
|
||||
{"omitted implies vendor", "", true, false},
|
||||
{"vendor only", `upstreams:["vendor"],`, true, false},
|
||||
{"vendor and new api", `upstreams:["vendor","new_api"],`, true, true},
|
||||
{"new api only still serves its vendor", `upstreams:["new_api"],`, true, true},
|
||||
{"unknown kind", `upstreams:["gateway"],`, false, false},
|
||||
{"duplicate", `upstreams:["new_api","new_api"],`, false, false},
|
||||
{"null", `upstreams:null,`, false, false},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
plugin, err := CompilePlugin(routingTestPluginSource("upstreams", 0, `["model"]`, tc.metadata, ""), Options{})
|
||||
if !tc.valid {
|
||||
require.Error(t, err)
|
||||
return
|
||||
}
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, ValidateV1Meta(plugin.Meta))
|
||||
assert.True(t, plugin.Meta.SupportsUpstream(UpstreamKindVendor))
|
||||
assert.Equal(t, tc.newAPI, plugin.Meta.SupportsUpstream(UpstreamKindNewAPI))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestSubmitResponseTypesContract(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name, metadata, hook string
|
||||
@@ -1207,6 +1246,9 @@ func TestSubmitResponseTypesContract(t *testing.T) {
|
||||
{"host JSON utility", `requiredCapabilities:["json-clone@1"],`, "", true},
|
||||
{"SSE delta", `submitResponseTypes:["sse"],requiredCapabilities:["submit-sse-delta@1"],`, `export function parseSubmitEventDelta(){return {changes:[],state:null,done:true};}`, true},
|
||||
{"SSE delta missing hook", `submitResponseTypes:["sse"],requiredCapabilities:["submit-sse-delta@1"],`, `export function parseSubmitEvent(){return {state:null,done:true};}`, false},
|
||||
{"SSE delta hook without declaration", `submitResponseTypes:["sse"],`, `export function parseSubmitEventDelta(){return {changes:[],state:null,done:true};}`, true},
|
||||
{"SSE snapshot and delta hooks", `submitResponseTypes:["sse"],`, `export function parseSubmitEvent(){return {state:null,done:true};}
|
||||
export function parseSubmitEventDelta(){return {changes:[],state:null,done:true};}`, true},
|
||||
{"delta requires SSE", `requiredCapabilities:["submit-sse-delta@1"],`, "", false},
|
||||
{"unsupported capability version", `requiredCapabilities:["json-clone@2"],`, "", false},
|
||||
{"duplicate capability", `requiredCapabilities:["json-clone@1","json-clone@1"],`, "", false},
|
||||
|
||||
Reference in new issue
Block a user