Implement global vendor mappings with bundle support and seen-based ignore

This commit is contained in:
Mikhail Chusavitin
2026-02-18 19:54:07 +03:00
parent b94dd3d015
commit c22328bf03
21 changed files with 2048 additions and 342 deletions

View File

@@ -0,0 +1,33 @@
package lotmatch
import (
"testing"
"git.mchus.pro/mchus/priceforge/internal/models"
)
func TestResolveWithVendorFallback(t *testing.T) {
matcher := NewMappingMatcher(
[]models.LotPartnumber{
{Vendor: "VendorA", Partnumber: "PN-1", LotName: "LOT_VENDOR_A"},
{Vendor: "", Partnumber: "PN-1", LotName: "LOT_FALLBACK"},
},
[]models.Lot{{LotName: "LOT_VENDOR_A"}, {LotName: "LOT_FALLBACK"}},
)
lot, typ, err := matcher.ResolveWithVendor("PN-1", "VendorA")
if err != nil {
t.Fatalf("ResolveWithVendor exact error: %v", err)
}
if lot != "LOT_VENDOR_A" || typ != "mapping" {
t.Fatalf("expected vendor lot, got lot=%s typ=%s", lot, typ)
}
lot, typ, err = matcher.ResolveWithVendor("PN-1", "UnknownVendor")
if err != nil {
t.Fatalf("ResolveWithVendor fallback error: %v", err)
}
if lot != "LOT_FALLBACK" || typ != "mapping" {
t.Fatalf("expected fallback lot, got lot=%s typ=%s", lot, typ)
}
}