feat: publish v1.0.0-rc.36-custom.1
Publish Docker image (Multi-arch) / Build & push (amd64) (push) Failing after 9m20s
Release (Linux, macOS, Windows) / Linux Release (push) Failing after 55m7s
Publish Docker image (Multi-arch) / Build & push (arm64) (push) Canceled after 0s
Release (Linux, macOS, Windows) / macOS Release (push) Canceled after 0s
Release (Linux, macOS, Windows) / Windows Release (push) Canceled after 0s
Publish Docker image (Multi-arch) / Create multi-arch manifests (push) Canceled after 0s
Publish Docker image (Multi-arch) / Build & push (amd64) (push) Failing after 9m20s
Release (Linux, macOS, Windows) / Linux Release (push) Failing after 55m7s
Publish Docker image (Multi-arch) / Build & push (arm64) (push) Canceled after 0s
Release (Linux, macOS, Windows) / macOS Release (push) Canceled after 0s
Release (Linux, macOS, Windows) / Windows Release (push) Canceled after 0s
Publish Docker image (Multi-arch) / Create multi-arch manifests (push) Canceled after 0s
This commit is contained in:
commit
bb7968b612
2381 files changed
+551494
No files matched your search
@@ -0,0 +1,100 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/QuantumNous/new-api/constant"
|
||||
"github.com/QuantumNous/new-api/relaykit/dto"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestChannelValidateSettingsRejectsInvalidHTTPTransport(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
setting dto.ChannelSettings
|
||||
wantErr string
|
||||
}{
|
||||
{
|
||||
name: "auto with shards is valid",
|
||||
setting: dto.ChannelSettings{HTTPProtocol: "auto", HTTP2ConnectionShards: 4},
|
||||
},
|
||||
{
|
||||
name: "http1 with shards greater than one rejected",
|
||||
setting: dto.ChannelSettings{HTTPProtocol: "http1", HTTP2ConnectionShards: 2},
|
||||
wantErr: "http2_connection_shards",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
channel := &Channel{}
|
||||
channel.SetSetting(tt.setting)
|
||||
err := channel.ValidateSettings()
|
||||
if tt.wantErr == "" {
|
||||
require.NoError(t, err)
|
||||
return
|
||||
}
|
||||
require.Error(t, err)
|
||||
assert.Contains(t, err.Error(), tt.wantErr)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestAdvancedCustomChannelRequiresModelListRouteOnlyWhenUpdateChecksEnabled(t *testing.T) {
|
||||
inferenceRoute := dto.AdvancedCustomRoute{
|
||||
IncomingPath: "/v1/chat/completions",
|
||||
UpstreamPath: "/v1/chat/completions",
|
||||
Converter: "none",
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
checksEnabled bool
|
||||
routes []dto.AdvancedCustomRoute
|
||||
wantErr string
|
||||
}{
|
||||
{
|
||||
name: "legacy channel without discovery route remains valid",
|
||||
routes: []dto.AdvancedCustomRoute{inferenceRoute},
|
||||
},
|
||||
{
|
||||
name: "enabled checks require discovery route",
|
||||
checksEnabled: true,
|
||||
routes: []dto.AdvancedCustomRoute{inferenceRoute},
|
||||
wantErr: dto.AdvancedCustomModelListPath,
|
||||
},
|
||||
{
|
||||
name: "enabled checks accept discovery route",
|
||||
checksEnabled: true,
|
||||
routes: []dto.AdvancedCustomRoute{
|
||||
inferenceRoute,
|
||||
{
|
||||
IncomingPath: dto.AdvancedCustomModelListPath,
|
||||
UpstreamPath: dto.AdvancedCustomModelListPath,
|
||||
Converter: "none",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
channel := &Channel{Type: constant.ChannelTypeAdvancedCustom}
|
||||
channel.SetOtherSettings(dto.ChannelOtherSettings{
|
||||
UpstreamModelUpdateCheckEnabled: tt.checksEnabled,
|
||||
AdvancedCustom: &dto.AdvancedCustomConfig{
|
||||
Routes: tt.routes,
|
||||
},
|
||||
})
|
||||
|
||||
err := channel.ValidateSettings()
|
||||
if tt.wantErr == "" {
|
||||
require.NoError(t, err)
|
||||
return
|
||||
}
|
||||
require.Error(t, err)
|
||||
assert.Contains(t, err.Error(), tt.wantErr)
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user