fix
This commit is contained in:
1 parent
feebf7d3c1
commit
486502852e
41 files changed
+1311
-259
No files matched your search
@@ -0,0 +1,25 @@
|
||||
package feeds
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestFeedLocaleSameProductIndependentMappings(t *testing.T) {
|
||||
id := uuid.MustParse("12345678-1234-1234-1234-123456789abc")
|
||||
old := map[string]existingProduct{"100": {
|
||||
ID: id,
|
||||
MappedData: []byte(`{"name":"English name"}`),
|
||||
SourceLocalizations: []byte(`{"en":{"name":"English name"},"sl":{"name":"Slovensko ime"}}`),
|
||||
}}
|
||||
same := []pendingProduct{{GTIN: "100", RawData: map[string]string{"EAN": "100"}, MappedData: map[string]any{"name": "Slovensko ime"}}}
|
||||
ops, skip := classifyUpsertOps(same, old, syncLocale{code: "sl", primary: false})
|
||||
if skip != 0 || len(ops) != 1 || ops[0].kind != upsertOpTouch {
|
||||
t.Fatalf("unchanged localized product should be touched, got %+v, skipped %d", ops, skip)
|
||||
}
|
||||
changed := []pendingProduct{{GTIN: "100", RawData: map[string]string{"EAN": "100"}, MappedData: map[string]any{"name": "Novejše ime"}}}
|
||||
ops, skip = classifyUpsertOps(changed, old, syncLocale{code: "sl", primary: false})
|
||||
if skip != 0 || len(ops) != 1 || ops[0].kind != upsertOpUpdate {
|
||||
t.Fatalf("changed localized product should update, got %+v, skipped %d", ops, skip)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user