test conf load env

This commit is contained in:
Bel LaPointe
2026-02-04 09:15:46 -07:00
parent 4b8f30865a
commit 1c81b4841a

32
src/config_test.go Normal file
View File

@@ -0,0 +1,32 @@
package src
import (
"os"
"testing"
)
func TestConfigLoadEnv(t *testing.T) {
c := Config{
Listen: "default",
Forwards: "default",
Hello: "default",
}
os.Setenv("LISTEN", "$LISTEN")
os.Setenv("FORWARDS", "")
os.Setenv("HELLO_B64", "$HELLO_B64")
if err := c.loadEnv(); err != nil {
t.Fatal(err)
}
if c.Listen != "$LISTEN" {
t.Error("listen", c.Listen)
}
if c.Forwards != "default" {
t.Error("forwards", c.Forwards)
}
if c.Hello != "$HELLO_B64" {
t.Error("hello", c.Hello)
}
}