This commit is contained in:
2026-08-23 23:14:57 +02:00
parent 296dc3c841
commit a246ed8fe5
6 changed files with 399 additions and 38 deletions
@@ -2,6 +2,7 @@ package processing
import (
"context"
"errors"
"strings"
"testing"
)
@@ -62,28 +63,24 @@ func TestTryAICategorize_rejectsInventedID(t *testing.T) {
}},
Vector: NoopVectorCategorizer{},
}
// An id outside the taxonomy means the category could not be determined. The
// product must fail rather than continue uncategorised into enhance, which
// would generate copy with no formula behind it.
out, err := e.RunSteps(context.Background(), "co", ProductInput{
Name: "Widget",
CategoryNamesByUID: map[string]string{
"50": "Štedilniki",
},
}, "full", nil, StepPolicy{AllowAI: true})
if err != nil {
t.Fatal(err)
if !errors.Is(err, ErrCategoryNotFound) {
t.Fatalf("err=%v want ErrCategoryNotFound", err)
}
if !strings.Contains(err.Error(), "99999") {
t.Fatalf("error should name the rejected id, got %v", err)
}
if out.Category != "" {
t.Fatalf("Category=%q want empty (invented id rejected)", out.Category)
}
found := false
for _, n := range out.Notes {
if strings.Contains(n, "ai_categorize: ignored") {
found = true
break
}
}
if !found {
t.Fatalf("expected reject note, got %v", out.Notes)
}
}
func TestTryAICategorize_resolvesDisplayName(t *testing.T) {