package domain

import (
	"net"
	"net/netip"
	"path/filepath"
	"strconv"
	"testing"
)

type Config struct {
	ContentDir string `env:"CONTENT_DIR" envDefault:"content"`
	Host       string `env:"HOST" envDefault:"0.0.0.0"`
	ThemeDir   string `env:"THEME_DIR" envDefault:"theme"`
	StaticDir  string `env:"STATIC_DIR" envDefault:"static"`
	CertKey    string `env:"CERT_KEY"`
	CertFile   string `env:"CERT_FILE"`
	Port       uint16 `env:"PORT" envDefault:"3000"`
}

func TestConfig(tb testing.TB) *Config {
	tb.Helper()

	return &Config{
		ContentDir: filepath.Join("testdata", "content"),
		Host:       "0.0.0.0",
		ThemeDir:   filepath.Join("testdata", "theme"),
		StaticDir:  filepath.Join("testdata", "static"),
		Port:       3000,
	}
}

func (c Config) AddrPort() netip.AddrPort {
	return netip.MustParseAddrPort(net.JoinHostPort(c.Host, strconv.FormatUint(uint64(c.Port), 10)))
}
