34 lines
923 B
Go
34 lines
923 B
Go
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)
|
|
}
|
|
}
|