Files
sub2api-cn-relay-manager/internal/host/sub2api/capability_inventory_test.go

77 lines
2.2 KiB
Go
Raw Normal View History

package sub2api
import (
"testing"
"sub2api-cn-relay-manager/internal/probe"
)
func TestBuildCapabilityInventoryClassifiesSupportedWithAdapter(t *testing.T) {
t.Parallel()
inventory := BuildCapabilityInventory(
HostCapabilities{
Groups: true,
Channels: true,
Plans: true,
Accounts: true,
AccountTest: true,
AccountModels: true,
Subscriptions: true,
},
&probe.CapabilityProfile{
TransportProfile: probe.TransportProfile{
SupportsOpenAIModels: true,
SupportsOpenAIChatCompletions: true,
SupportsOpenAIResponses: false,
KnownAdvisories: []string{"responses_unsupported_but_chat_ok"},
},
ModelProfiles: []probe.ModelCapabilityProfile{{
RawModelID: "kimi-k2.6",
CanonicalModelFamily: "kimi-k2.6",
SmokeChatOK: true,
}},
},
)
if !inventory.HostReady {
t.Fatal("HostReady = false, want true")
}
if len(inventory.Models) != 1 {
t.Fatalf("len(Models) = %d, want 1", len(inventory.Models))
}
if inventory.Models[0].SupportLevel != SupportLevelWithPluginAdapter {
t.Fatalf("SupportLevel = %q, want %q", inventory.Models[0].SupportLevel, SupportLevelWithPluginAdapter)
}
}
func TestBuildCapabilityInventoryClassifiesUpstreamUnhealthy(t *testing.T) {
t.Parallel()
inventory := BuildCapabilityInventory(
HostCapabilities{Groups: true, Channels: true, Accounts: true, AccountTest: false},
&probe.CapabilityProfile{
TransportProfile: probe.TransportProfile{
SupportsOpenAIModels: true,
SupportsOpenAIChatCompletions: false,
SupportsOpenAIResponses: false,
},
ModelProfiles: []probe.ModelCapabilityProfile{{
RawModelID: "glm-4.5",
CanonicalModelFamily: "glm-4.5",
SmokeChatOK: false,
}},
},
)
if inventory.HostReady {
t.Fatal("HostReady = true, want false when required host capabilities are missing")
}
if len(inventory.Models) != 1 {
t.Fatalf("len(Models) = %d, want 1", len(inventory.Models))
}
if inventory.Models[0].SupportLevel != SupportLevelUpstreamUnhealthy {
t.Fatalf("SupportLevel = %q, want %q", inventory.Models[0].SupportLevel, SupportLevelUpstreamUnhealthy)
}
}