31 lines
650 B
Go
31 lines
650 B
Go
package domain
|
|
|
|
import (
|
|
"net"
|
|
"net/netip"
|
|
"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/"`
|
|
Port uint16 `env:"PORT" envDefault:"3000"`
|
|
}
|
|
|
|
func TestConfig(tb testing.TB) *Config {
|
|
tb.Helper()
|
|
|
|
return &Config{
|
|
ContentDir: "testdata/content/",
|
|
Host: "0.0.0.0",
|
|
ThemeDir: "testdata/theme/",
|
|
Port: 3000,
|
|
}
|
|
}
|
|
|
|
func (c Config) AddrPort() netip.AddrPort {
|
|
return netip.MustParseAddrPort(net.JoinHostPort(c.Host, strconv.FormatUint(uint64(c.Port), 10)))
|
|
}
|