package domain_test

import (
	"testing"
	"time"

	"gitea.dwysokinski.me/twhelp/corev3/internal/domain"
	"gitea.dwysokinski.me/twhelp/corev3/internal/domain/domaintest"
	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
)

func TestNewCreateSnapshotsCmdPayload(t *testing.T) {
	t.Parallel()

	version := domaintest.NewVersion(t)
	server := domaintest.NewServer(t, func(cfg *domaintest.ServerConfig) {
		cfg.VersionCode = version.Code()
	})
	date := time.Now()

	payload, err := domain.NewCreateSnapshotsCmdPayload(server.Key(), version.Code(), version.Timezone(), date)
	require.NoError(t, err)
	assert.Equal(t, server.Key(), payload.ServerKey())
	assert.Equal(t, version.Code(), payload.VersionCode())
	assert.Equal(t, version.Timezone(), payload.VersionTimezone())
	assert.Equal(t, date, payload.Date())
}

func TestNewSnapshotsCreatedEventPayload(t *testing.T) {
	t.Parallel()

	server := domaintest.NewServer(t)

	payload, err := domain.NewSnapshotsCreatedEventPayload(server.Key(), server.VersionCode())
	require.NoError(t, err)
	assert.Equal(t, server.Key(), payload.ServerKey())
	assert.Equal(t, server.VersionCode(), payload.VersionCode())
}
