Files
greeneclipse 8580c996c3 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.
2026-08-09 22:47:43 +02:00

41 lines
1.1 KiB
Go

package campaigns
import (
"testing"
"github.com/google/uuid"
)
func TestValidateCampaignRefs(t *testing.T) {
okCats := make([]uuid.UUID, maxCampaignCategoryIDs)
okProds := make([]uuid.UUID, maxCampaignProductIDs)
for i := range okCats {
okCats[i] = uuid.New()
}
for i := range okProds {
okProds[i] = uuid.New()
}
if err := validateCampaignRefs(okCats, okProds); err != nil {
t.Fatalf("expected ok, got %v", err)
}
tooManyCats := append(append([]uuid.UUID{}, okCats...), uuid.New())
if err := validateCampaignRefs(tooManyCats, nil); err != ErrTooManyCategoryIDs {
t.Fatalf("got %v want ErrTooManyCategoryIDs", err)
}
tooManyProds := append(append([]uuid.UUID{}, okProds...), uuid.New())
if err := validateCampaignRefs(nil, tooManyProds); err != ErrTooManyProductIDs {
t.Fatalf("got %v want ErrTooManyProductIDs", err)
}
}
func TestClientErrorTooManyRefs(t *testing.T) {
for _, err := range []error{ErrTooManyProductIDs, ErrTooManyCategoryIDs} {
msg, ok := ClientError(err)
if !ok || msg == "" {
t.Fatalf("ClientError(%v) ok=%v msg=%q", err, ok, msg)
}
}
}