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,42 @@
|
||||
package woocommerce
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
func TestApplyProductSyncScope(t *testing.T) {
|
||||
opt := SyncOptions{SyncLimit: defaultSyncLimit}
|
||||
id := uuid.New().String()
|
||||
err := applyProductSyncScope(&opt, ProductSyncScope{
|
||||
Limit: 25,
|
||||
Status: "needs_review",
|
||||
Category: "Sofas",
|
||||
ProductIDs: []string{id},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if opt.SyncLimit != 25 || opt.SyncFilterStatus != "needs_review" || opt.SyncFilterCategory != "Sofas" {
|
||||
t.Fatalf("opt=%#v", opt)
|
||||
}
|
||||
if len(opt.SyncOnlyIDs) != 1 || opt.SyncOnlyIDs[0] != id {
|
||||
t.Fatalf("ids=%v", opt.SyncOnlyIDs)
|
||||
}
|
||||
if err := applyProductSyncScope(&opt, ProductSyncScope{Status: "bad"}); !errors.Is(err, ErrInvalidSyncScope) {
|
||||
t.Fatalf("err=%v", err)
|
||||
}
|
||||
if err := applyProductSyncScope(&opt, ProductSyncScope{Category: strings.Repeat("x", maxCategoryFilterLen+1)}); !errors.Is(err, ErrInvalidSyncScope) {
|
||||
t.Fatalf("category length err=%v", err)
|
||||
}
|
||||
tooMany := make([]string, maxSyncOnlyIDs+1)
|
||||
for i := range tooMany {
|
||||
tooMany[i] = uuid.New().String()
|
||||
}
|
||||
if err := applyProductSyncScope(&opt, ProductSyncScope{ProductIDs: tooMany}); !errors.Is(err, ErrInvalidSyncScope) {
|
||||
t.Fatalf("product_ids max err=%v", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user