package reliable

import (
	"testing"

	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
	"github.com/tech/sendico/pkg/model"
	"go.uber.org/zap"
)

func TestNewReliableProducerFromConfigUsesDefaults(t *testing.T) {
	producer, settings, err := NewReliableProducerFromConfig(zap.NewNop(), &recordingDirectProducer{}, &recordingStore{}, model.SettingsT{})
	require.NoError(t, err)
	require.NotNil(t, producer)
	assert.Equal(t, DefaultSettings(), settings)
}

func TestNewReliableProducerFromConfigCanDisable(t *testing.T) {
	producer, settings, err := NewReliableProducerFromConfig(zap.NewNop(), &recordingDirectProducer{}, &recordingStore{}, model.SettingsT{
		SettingsBlockKey: map[string]any{
			"enabled": false,
		},
	})
	require.NoError(t, err)
	assert.Nil(t, producer)
	assert.False(t, settings.Enabled)
}
