Implement global vendor mappings with bundle support and seen-based ignore
This commit is contained in:
33
internal/lotmatch/matcher_test.go
Normal file
33
internal/lotmatch/matcher_test.go
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user