package affiliates import ( "Rezina-Backend/internal/domain" "context" "errors" "testing" ) func TestAffiliateMutationsValidateBeforeStorage(t *testing.T) { s := NewService(nil) ctx := context.Background() tests := []func() error{ func() error { _, e := s.Apply(ctx, 42, domain.AffiliateApplicationInput{Application: "I promote makeup courses", AcceptTerms: false, TermsVersion: "1"}) return e }, func() error { _, e := s.Apply(ctx, 42, domain.AffiliateApplicationInput{Application: "I promote makeup courses", AcceptTerms: true, TermsVersion: "old"}) return e }, func() error { _, e := s.Review(ctx, 42, 1, domain.AffiliateReviewInput{Status: "APPROVED", Note: " "}) return e }, func() error { _, e := s.RequestPayout(ctx, 42, domain.AffiliatePayoutInput{}); return e }, func() error { _, e := s.ReviewPayout(ctx, 1, 1, domain.AffiliatePayoutReviewInput{Status: "PAID", Note: "Paid externally"}) return e }, func() error { _, e := s.Reverse(ctx, 1, 1, ""); return e }, } for i, fn := range tests { if err := fn(); !errors.Is(err, domain.ErrAffiliateInput) { t.Fatalf("case %d: %v", i, err) } } }