bingobot/internal/config/config_test.go

38 lines
620 B
Go
Raw Normal View History

package config
2024-11-06 13:32:37 -08:00
import (
"testing"
"github.com/spf13/viper"
)
var testConfig string
func init() {
testConfig = `
log_file: "bingobot.log"
log_dir: "log"
log_max_size_mb: 500
log_max_backups: 3
log_max_age_days: 365
log_compression: false
`
// the config file is stored in the project root
viper.AddConfigPath("../..")
2024-11-06 13:32:37 -08:00
}
// test that default configs are working
func TestDefaultConfigs(t *testing.T) {
k := "testdefaultkey"
v := "testdefaultval"
viper.SetDefault(k, v)
if err := Init(); err != nil {
2024-11-06 13:32:37 -08:00
t.Error(err)
}
if viper.GetString(k) != v {
t.Errorf("want %s, got %s", v, viper.GetString(k))
}
}