33 lines
513 B
Go
33 lines
513 B
Go
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)
|
|
}
|
|
}
|