package benefactoraddressvalidator

import (
	"context"
	"testing"

	addressparam "git.gocasts.ir/ebhomengo/niki/param/benefactor/address"
	"github.com/stretchr/testify/assert"
)

func TestValidator_ValidateGetAddress(t *testing.T) {
	mockRepository := NewMockRepository(t)
	validator := New(mockRepository)
	ctx := context.Background()

	t.Run("Successful validation", func(t *testing.T) {
		req := addressparam.GetAddressRequest{
			AddressID:    1,
			BenefactorID: 1,
		}

		fieldErrors, err := validator.ValidateGetAddress(ctx, req)

		assert.NoError(t, err)
		assert.Nil(t, fieldErrors)
	})

	t.Run("Empty address id", func(t *testing.T) {
		req := addressparam.GetAddressRequest{
			AddressID:    0,
			BenefactorID: 1,
		}

		fieldErrors, err := validator.ValidateGetAddress(ctx, req)

		assert.Error(t, err)
		assert.NotNil(t, fieldErrors)
		assert.Contains(t, fieldErrors, "AddressID")
	})
}
