mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
add config tests
This commit is contained in:
parent
6b5a0ec6ac
commit
595115945c
|
@ -32,3 +32,9 @@ func LoadConfig() *Config {
|
|||
|
||||
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
20
pkg/config/config_test.go
Normal 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)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
Loading…
Reference in a new issue