fix
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user