🧑‍💻 Created TestConfig helper

This commit is contained in:
Maxim Lebedev 2023-11-09 23:29:45 +06:00
parent c361321012
commit 020a6f98e5
Signed by: toby3d
GPG Key ID: 1F14E25B7C119FC5
1 changed files with 12 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import (
"net"
"net/netip"
"strconv"
"testing"
)
type Config struct {
@ -13,6 +14,17 @@ type Config struct {
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)))
}