package types

import (
	"testing"

	"github.com/go-playground/validator/v10"
)

func TestPromoPriceItemsMustNotBeEmpty(t *testing.T) {
	validate := validator.New()
	req := SetPromoPriceRequest{
		PromoRuleId: 1,
		Items:       []PromoPriceItem{},
	}

	if err := validate.Struct(req); err == nil {
		t.Fatal("expected empty promo price items to fail validation")
	}
}

func TestPromoListPageSizeLimit(t *testing.T) {
	validate := validator.New()
	tests := []struct {
		name string
		req  any
	}{
		{
			name: "rule list",
			req: GetPromoRuleListRequest{
				Page: 1,
				Size: 201,
			},
		},
		{
			name: "price list",
			req: GetPromoPriceListRequest{
				RuleId: 1,
				Page:   1,
				Size:   201,
			},
		},
		{
			name: "usage list",
			req: GetPromoUsageListRequest{
				Page: 1,
				Size: 201,
			},
		},
	}

	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if err := validate.Struct(tt.req); err == nil {
				t.Fatal("expected page size greater than 200 to fail validation")
			}
		})
	}
}
