Files
TradarrV2/backend/internal/server/server_test.go
Blomios 4459a81206 test(e2e): add isolated browser journey and cleanup supervision
Add a fake-only end-to-end stack, Firefox journey, and bounded process cleanup for normal, failed, and interrupted runs.

Refs #12

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-20 23:39:02 +01:00

41 lines
1.5 KiB
Go

package server
import (
"context"
"net/http/httptest"
"testing"
"github.com/tradarr/backend/internal/ai"
"github.com/tradarr/backend/internal/auth"
"github.com/tradarr/backend/internal/config"
"github.com/tradarr/backend/internal/generation"
"github.com/tradarr/backend/internal/indices"
)
type fakeGeneration struct{}
func (fakeGeneration) Generate(context.Context, string) (generation.Result, error) {
return generation.Result{Outcome: generation.GenerationOutcome{Status: "no_results"}}, nil
}
type fakeSearch struct{ calls int }
func (f *fakeSearch) Search(context.Context, string, int) ([]indices.Index, error) {
f.calls++
return []indices.Index{}, nil
}
func TestInjectableCompositionDoesNotStartSchedulerOrNeedDatabase(t *testing.T) {
search := &fakeSearch{}
factoryCalls := 0
app := New(nil, &config.Config{JWTSecret: "composition-test"}, Dependencies{IndexSearcher: search, GenerationFactory: func(*ai.Pipeline) generation.UseCase { factoryCalls++; return fakeGeneration{} }, EnableScheduler: false})
defer app.Close()
token, _ := auth.GenerateToken("owner", "owner@example.test", "user", "composition-test")
request := httptest.NewRequest("GET", "/api/indices/search?q=test", nil)
request.Header.Set("Authorization", "Bearer "+token)
response := httptest.NewRecorder()
app.Router.ServeHTTP(response, request)
if response.Code != 200 || search.calls != 1 || factoryCalls != 1 {
t.Fatalf("status=%d search=%d factory=%d", response.Code, search.calls, factoryCalls)
}
}