add config tests

This commit is contained in:
lyx0 2021-10-28 23:31:59 +02:00
parent 6b5a0ec6ac
commit 595115945c
2 changed files with 26 additions and 0 deletions

View file

@ -32,3 +32,9 @@ func LoadConfig() *Config {
return cfg return cfg
} }
// Only for tests
func LoadConfigTest() {
os.Setenv("TEST_VALUE", "xDLUL420")
// defer os.Unsetenv("TEST_VALUE")
}

20
pkg/config/config_test.go Normal file
View file

@ -0,0 +1,20 @@
package config
import (
"os"
"testing"
)
func TestLoadConfig(t *testing.T) {
t.Run("loads a testing value from the .env file", func(t *testing.T) {
LoadConfigTest()
got := os.Getenv("TEST_VALUE")
want := "xDLUL420"
if got != want {
t.Errorf("got %q, want %q", got, want)
}
})
}