OpenAI-compatible AI gateway with Vue admin UI, multi-provider egress, ingress key governance, monitoring, and security controls. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package gateway
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/rose_cat707/luminary/internal/model"
|
||||
"github.com/rose_cat707/luminary/internal/provider"
|
||||
)
|
||||
|
||||
func TestIsHealthCheckHTTPStatus(t *testing.T) {
|
||||
cases := map[int]bool{
|
||||
200: true,
|
||||
204: true,
|
||||
400: true,
|
||||
422: true,
|
||||
401: false,
|
||||
404: false,
|
||||
500: false,
|
||||
}
|
||||
for code, want := range cases {
|
||||
if got := isHealthCheckHTTPStatus(code); got != want {
|
||||
t.Fatalf("code %d: got %v want %v", code, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestHealthCheckEndpointsEmbedding(t *testing.T) {
|
||||
s := &Service{}
|
||||
p := &model.Provider{
|
||||
Category: model.CategoryEmbedding,
|
||||
Type: model.ProviderOpenAI,
|
||||
AllowedEndpointsJSON: `["embeddings"]`,
|
||||
}
|
||||
eps := s.healthCheckEndpoints(p)
|
||||
if len(eps) != 1 || eps[0] != provider.EndpointEmbeddings {
|
||||
t.Fatalf("got %v", eps)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHealthCheckEndpointsEmbeddingWithListModels(t *testing.T) {
|
||||
s := &Service{}
|
||||
p := &model.Provider{
|
||||
Category: model.CategoryEmbedding,
|
||||
Type: model.ProviderOpenAI,
|
||||
AllowedEndpointsJSON: `["list_models","embeddings"]`,
|
||||
}
|
||||
eps := s.healthCheckEndpoints(p)
|
||||
if len(eps) != 2 || eps[0] != provider.EndpointListModels || eps[1] != provider.EndpointEmbeddings {
|
||||
t.Fatalf("got %v", eps)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user