Files
TradarrV2/backend/internal/ai/generation_ticket14_test.go
Blomios 989996fbd6 feat(ai): add personal summary models and retire Q&A
Add an admin-managed provider model catalog with per-user summary selection, migration backfill, and generation snapshots. Retire report creation and messaging while preserving owner-scoped history.

Refs #15 #16

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

52 lines
1.3 KiB
Go

package ai
import (
"go/ast"
"go/parser"
"go/token"
"os"
"testing"
)
// The legacy filter role must never act as an implicit Laya implementation.
// Keep this guard local and deterministic: it inspects the adapter's AST and
// makes no provider or network calls.
func TestGenerationRankerDoesNotFallBackToLegacyFilterProvider(t *testing.T) {
file, err := parser.ParseFile(token.NewFileSet(), "generation.go", mustReadGenerationSource(t), 0)
if err != nil {
t.Fatal(err)
}
for _, declaration := range file.Decls {
fn, ok := declaration.(*ast.FuncDecl)
if !ok || fn.Recv == nil || fn.Name.Name != "Rank" {
continue
}
ast.Inspect(fn.Body, func(node ast.Node) bool {
call, ok := node.(*ast.CallExpr)
if !ok || len(call.Args) != 1 {
return true
}
selector, ok := call.Fun.(*ast.SelectorExpr)
if !ok || selector.Sel.Name != "buildProviderForRole" {
return true
}
role, ok := call.Args[0].(*ast.BasicLit)
if ok && role.Kind == token.STRING && role.Value == `"filter"` {
t.Errorf("generationRanker resolves legacy filter provider; Laya must be a dedicated ranker")
}
return true
})
return
}
t.Fatal("generationRanker.Rank declaration not found")
}
func mustReadGenerationSource(t *testing.T) []byte {
t.Helper()
data, err := os.ReadFile("generation.go")
if err != nil {
t.Fatal(err)
}
return data
}