fixes
This commit is contained in:
1 parent
c347d2418f
commit
1ad180a052
49 files changed
+6339
-89
No files matched your search
@@ -2,7 +2,6 @@ package processing
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -37,27 +36,28 @@ func categorizeInput() ProductInput {
|
||||
|
||||
// The reported case: the model always answers with SOME id, so a low score is it
|
||||
// saying "I do not know". Taking it at face value files a camping chair under
|
||||
// Generators and then drives that category's formula.
|
||||
func TestRunSteps_lowConfidenceCategoryFailsTheProduct(t *testing.T) {
|
||||
// Generators and then drives that category's formula. The guess is discarded, but
|
||||
// the product still processes uncategorized (supplier feeds often have no category).
|
||||
func TestRunSteps_lowConfidenceCategoryProcessesUncategorized(t *testing.T) {
|
||||
t.Parallel()
|
||||
e, enhanceCalls := categorizeEngine(`{"categoryId":"1","confidence":0.08}`)
|
||||
|
||||
out, err := e.RunSteps(context.Background(), "co", categorizeInput(), "full", nil,
|
||||
StepPolicy{AllowAI: true})
|
||||
if !errors.Is(err, ErrCategoryNotFound) {
|
||||
t.Fatalf("err=%v want ErrCategoryNotFound", err)
|
||||
}
|
||||
for _, want := range []string{"0.08", "0.75"} {
|
||||
if !strings.Contains(err.Error(), want) {
|
||||
t.Fatalf("error should report the score and the minimum, got %v", err)
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("an undetermined category must not fail the product, got %v", err)
|
||||
}
|
||||
if out.Category != "" {
|
||||
t.Fatalf("a rejected pick must not be persisted, got %q", out.Category)
|
||||
}
|
||||
// The whole point: stop before spending an enhance call on the wrong category.
|
||||
if *enhanceCalls != 0 {
|
||||
t.Fatalf("enhance ran %d time(s) after the category was rejected", *enhanceCalls)
|
||||
notes := strings.Join(out.Notes, " ")
|
||||
for _, want := range []string{"0.08", "0.75"} {
|
||||
if !strings.Contains(notes, want) {
|
||||
t.Fatalf("notes should report the score and the minimum, got %v", out.Notes)
|
||||
}
|
||||
}
|
||||
if *enhanceCalls == 0 {
|
||||
t.Fatal("enhance should still run without a category")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user