This commit is contained in:
greeneclipse committed 2026-10-20 17:03:09 +02:00
1 parent 486502852e
commit 0e48ea427b
23 files changed
+386 -78

No files matched your search

@@ -107,3 +107,29 @@ func TestMapStockStatus_unknown(t *testing.T) {
t.Fatal("expected empty for unknown")
}
}
// Price, stock and availability are optional supplier attributes. A product
// must remain eligible for enrichment when the feed omits all of them.
func TestEnrichMappedWithoutSellingPriceOrStock(t *testing.T) {
raw := map[string]any{"EAN": "4005176605550", "name": "VitalioFlex Trend shower hose"}
got := EnrichMapped(raw)
for _, key := range []string{"price", "sale_price", "stock", "availability", "stock_status"} {
if value, ok := got[key]; ok {
t.Fatalf("invented %s=%v: %#v", key, value, got)
}
}
if got["gtin"] != "4005176605550" || got["title"] != raw["name"] {
t.Fatalf("product with optional fields missing was not enriched: %#v", got)
}
if _, ok := raw["price"]; ok {
t.Fatal("source modified")
}
normalized := NormalizeMapped(map[string]any{"name": "Shower hose", "price": "", "stock": nil}, nil)
if _, ok := normalized["price"]; ok {
t.Fatalf("empty price must remain absent: %#v", normalized)
}
if _, ok := normalized["stock"]; ok {
t.Fatalf("missing stock must remain absent: %#v", normalized)
}
}