test conf load env
This commit is contained in:
32
src/config_test.go
Normal file
32
src/config_test.go
Normal 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user