🧑💻 Created TestConfig helper
This commit is contained in:
parent
c361321012
commit
020a6f98e5
|
@ -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)))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue