Initial commit of Descrybe v2 without local scratch artifacts.
Drop one-shot tmp/axe scripts and agent i18n scratch so the Gitea tree is deployable.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package processing
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestFillMissingStandardFields(t *testing.T) {
|
||||
mapped := map[string]any{"title": "Widget"}
|
||||
raw := map[string]any{"ean": "1234567890123", "manufacturer": "Acme"}
|
||||
fields := []StandardFieldDef{
|
||||
{Key: "title", MappingHints: []string{"name"}},
|
||||
{Key: "gtin", MappingHints: []string{"ean", "upc"}},
|
||||
{Key: "brand", MappingHints: []string{"manufacturer"}},
|
||||
{Key: "currency", DefaultValue: "EUR"},
|
||||
{Key: "color", MappingHints: []string{"colour"}},
|
||||
}
|
||||
out := FillMissingStandardFields(mapped, raw, fields)
|
||||
if out["title"] != "Widget" {
|
||||
t.Fatalf("title=%v", out["title"])
|
||||
}
|
||||
if out["gtin"] != "1234567890123" {
|
||||
t.Fatalf("gtin=%v", out["gtin"])
|
||||
}
|
||||
if out["brand"] != "Acme" {
|
||||
t.Fatalf("brand=%v", out["brand"])
|
||||
}
|
||||
if out["currency"] != "EUR" {
|
||||
t.Fatalf("currency=%v", out["currency"])
|
||||
}
|
||||
if _, ok := out["color"]; ok {
|
||||
t.Fatalf("color should stay empty, got %v", out["color"])
|
||||
}
|
||||
if mapped["gtin"] != nil {
|
||||
t.Fatal("original mapped must not be mutated")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user