package usecase

import (
	"testing"

	notifconfig "gateway/internal/model/notification/config"

	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
)

func TestBuildEmailChain_MockByDefault(t *testing.T) {
	chain, err := buildEmailChain(notifconfig.Config{
		Email: notifconfig.EmailConfig{Provider: notifconfig.ProviderMock},
	}, nil)
	require.NoError(t, err)
	require.NotNil(t, chain)
}

func TestBuildEmailChain_SMTPAndSES(t *testing.T) {
	chain, err := buildEmailChain(notifconfig.Config{
		Email: notifconfig.EmailConfig{
			SMTP: notifconfig.SMTPProviderSettings{
				Enable: true,
				Sort:   1,
				Host:   "smtp.example.com",
				Port:   587,
			},
			SES: notifconfig.SESProviderSettings{
				Enable:    true,
				Sort:      2,
				Region:    "ap-northeast-1",
				AccessKey: "key",
				SecretKey: "secret",
			},
		},
	}, nil)
	require.NoError(t, err)
	require.NotNil(t, chain)
}

func TestBuildEmailChain_SESRequiresCredentials(t *testing.T) {
	_, err := buildEmailChain(notifconfig.Config{
		Email: notifconfig.EmailConfig{
			SES: notifconfig.SESProviderSettings{Enable: true, Region: "ap-northeast-1"},
		},
	}, nil)
	assert.Error(t, err)
}

func TestBuildSMSChain_Mitake(t *testing.T) {
	chain, err := buildSMSChain(notifconfig.Config{
		SMS: notifconfig.SMSConfig{
			Mitake: notifconfig.MitakeProviderSettings{
				Enable:   true,
				Sort:     1,
				User:     "user",
				Password: "pass",
			},
		},
	}, nil)
	require.NoError(t, err)
	require.NotNil(t, chain)
}
