feat(ai): add provider connection test (#38)

This commit is contained in:
2026-11-24 16:21:48 +01:00
parent 2e865204c8
commit 54fced1ffb
16 changed files with 599 additions and 18 deletions

View File

@ -0,0 +1,28 @@
package api_test
import (
"github.com/tradarr/backend/internal/api"
"github.com/tradarr/backend/internal/api/handlers"
"github.com/tradarr/backend/internal/config"
"net/http/httptest"
"testing"
)
func TestAIProviderConnectionRequiresAuthentication(t *testing.T) {
h := handlers.New(nil, &config.Config{}, nil, nil, nil, nil)
r := api.SetupRouter(h, "test-secret")
found := false
for _, route := range r.Routes() {
if route.Method == "POST" && route.Path == "/api/admin/ai-providers/:id/test" {
found = true
}
}
if !found {
t.Fatal("test route missing")
}
w := httptest.NewRecorder()
r.ServeHTTP(w, httptest.NewRequest("POST", "/api/admin/ai-providers/saved/test", nil))
if w.Code != 401 {
t.Fatalf("unauthenticated status=%d", w.Code)
}
}