diff --git a/src/config_test.go b/src/config_test.go new file mode 100644 index 0000000..0643b60 --- /dev/null +++ b/src/config_test.go @@ -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) + } +}