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,40 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user