Changeset 0.10.2 (#58)

This commit is contained in:
2026-02-24 20:29:08 +00:00
parent 13772ebd6c
commit 4061e4a145
20 changed files with 1223 additions and 41 deletions

View File

@@ -1611,6 +1611,7 @@ func TestIntegration_Roles_ListReturnsSeeded(t *testing.T) {
decode(w, &resp)
// Migration 004 seeds utility, embedding, generation
// (generation removed from ValidRoles in v0.10.2 but still in JSONB seed data)
for _, role := range []string{"utility", "embedding", "generation"} {
if _, ok := resp[role]; !ok {
t.Errorf("expected role %q in response, got: %v", role, resp)
@@ -2174,3 +2175,48 @@ func TestIntegration_Pricing_RejectBYOKUpsert(t *testing.T) {
t.Fatalf("pricing BYOK upsert: want 403, got %d: %s", w.Code, w.Body.String())
}
}
// ── GetRole Endpoint (exercises GetConfig signature) ──
// The existing Roles_UpdateAndGet test validates via ListRoles.
// This test hits GET /admin/roles/:role which routes through
// resolver.GetConfig — the exact call site that broke in v0.10.2
// when the signature changed from 3-arg to 4-arg.
func TestIntegration_Roles_GetSingleRole(t *testing.T) {
h := setupHarness(t)
_, adminToken := h.createAdminUser("admin_getrole", "admin_getrole@test.com")
// Create provider + configure utility role
w := h.request("POST", "/api/v1/admin/configs", adminToken, map[string]interface{}{
"name": "getrole-provider", "provider": "openai",
"endpoint": "http://localhost:1/v1", "api_key": "sk-getrole",
})
if w.Code != http.StatusCreated {
t.Fatalf("create config: %d: %s", w.Code, w.Body.String())
}
var cfg map[string]interface{}
decode(w, &cfg)
cfgID := cfg["id"].(string)
w = h.request("PUT", "/api/v1/admin/roles/utility", adminToken, map[string]interface{}{
"primary": map[string]string{
"provider_config_id": cfgID,
"model_id": "gpt-4o-mini",
},
})
if w.Code != http.StatusOK {
t.Fatalf("update role: %d: %s", w.Code, w.Body.String())
}
// GET /admin/roles/utility — the endpoint that broke
w = h.request("GET", "/api/v1/admin/roles/utility", adminToken, nil)
if w.Code != http.StatusOK {
t.Fatalf("get single role: want 200, got %d: %s", w.Code, w.Body.String())
}
// Seeded role with null config via GetRole → 200 (migration seeds all roles)
w = h.request("GET", "/api/v1/admin/roles/embedding", adminToken, nil)
if w.Code != http.StatusOK {
t.Fatalf("get seeded-but-empty role: want 200, got %d: %s", w.Code, w.Body.String())
}
}