Files
renjue 76ba500417
CI / docker (push) Successful in 2m4s
Initial commit: Luminary AI Gateway
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>
2026-06-23 21:46:16 +08:00

52 lines
1.2 KiB
Go

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)
}
}