mirror of
https://github.com/alibaba/higress.git
synced 2026-05-28 22:57:31 +08:00
test(ai-proxy): expand wasm integration tests, coverage, and provider matrix (#3790)
Signed-off-by: jingze <daijingze.djz@alibaba-inc.com>
This commit is contained in:
@@ -544,6 +544,19 @@ func TestFailover_FromJson_FailoverOnStatus(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestFailover_Validate(t *testing.T) {
|
||||
t.Run("missing_healthCheckModel", func(t *testing.T) {
|
||||
f := &failover{}
|
||||
f.FromJson(gjson.Parse(`{"enabled":true}`))
|
||||
assert.Error(t, f.Validate())
|
||||
})
|
||||
t.Run("ok_with_healthCheckModel", func(t *testing.T) {
|
||||
f := &failover{}
|
||||
f.FromJson(gjson.Parse(`{"enabled":true,"healthCheckModel":"gpt-4o-mini"}`))
|
||||
assert.NoError(t, f.Validate())
|
||||
})
|
||||
}
|
||||
|
||||
func TestHealthCheckEndpoint_Struct(t *testing.T) {
|
||||
t.Run("health_check_endpoint_fields", func(t *testing.T) {
|
||||
endpoint := HealthCheckEndpoint{
|
||||
@@ -679,6 +692,32 @@ func TestProviderConfig_SetDefaultCapabilities(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestCreateProvider(t *testing.T) {
|
||||
t.Run("generic_success", func(t *testing.T) {
|
||||
var pc ProviderConfig
|
||||
pc.FromJson(gjson.Parse(`{"type":"generic","genericHost":"http://127.0.0.1:8080","apiTokens":["t"]}`))
|
||||
p, err := CreateProvider(pc)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, providerTypeGeneric, p.GetProviderType())
|
||||
})
|
||||
|
||||
t.Run("openai_minimal_success", func(t *testing.T) {
|
||||
var pc ProviderConfig
|
||||
pc.FromJson(gjson.Parse(`{"type":"openai","apiTokens":["sk-test"]}`))
|
||||
p, err := CreateProvider(pc)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, providerTypeOpenAI, p.GetProviderType())
|
||||
})
|
||||
|
||||
t.Run("unknown_type", func(t *testing.T) {
|
||||
var pc ProviderConfig
|
||||
pc.FromJson(gjson.Parse(`{"type":"no-such-provider-xyz","apiTokens":["t"]}`))
|
||||
_, err := CreateProvider(pc)
|
||||
assert.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "unknown provider type")
|
||||
})
|
||||
}
|
||||
|
||||
func TestStripClaudeInternalMessageFields(t *testing.T) {
|
||||
body := []byte(`{
|
||||
"model":"claude",
|
||||
|
||||
Reference in New Issue
Block a user