Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package config
import (
"os"
"testing"
"time"
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
)
func TestInit(t *testing.T) {
viper.SetConfigFile("./config_test.toml")
viper.Set("baseSouthBoundType", 0)
viper.Set("baseSouthBoundUUID", "bf8160d4-4659-4a1b-98fd-f409a04111eb")
viper.Set("basePNDUUID", "bf8160d4-4659-4a1b-98fd-f409a04111ec")
viper.Set("GOSDN_CHANGE_TIMEOUT", "10m")
}
func TestUseExistingConfig(t *testing.T) {
TestInit(t)
err := InitializeConfig()
if err != nil {
t.Error(err)
return
}
if BasePndUUID.String() != "bf8160d4-4659-4a1b-98fd-f409a04111ec" {
t.Fatalf("BasePndUUID.String() is not bf8160d4-4659-4a1b-98fd-f409a04111ec. got=%s",
BasePndUUID.String())
}
if BaseSouthBoundUUID.String() != "bf8160d4-4659-4a1b-98fd-f409a04111eb" {
t.Fatalf("BaseSouthBoundUUID.String() is not bf8160d4-4659-4a1b-98fd-f409a04111eb. got=%s",
BaseSouthBoundUUID.String())
}
if BaseSouthBoundType != 1 {
t.Fatalf("BaseSouthBoundType is not 1. got=%d",
BaseSouthBoundType)
}
testChangeTimeout, _ := time.ParseDuration("10m")
defaultChangeTimeout := defaultTimeOutDuration10minutes
if defaultChangeTimeout != testChangeTimeout {
t.Fatalf("ChangeTimeout is not 10ms. got=%v",
ChangeTimeout)
}
if os.Getenv("GOSDN_LOG") == "nolog" {
if LogLevel != logrus.PanicLevel {
t.Fatalf("LogLevel is not %v. got=%v",
logrus.PanicLevel, LogLevel)
}
} else {
if LogLevel != logrus.InfoLevel {
t.Fatalf("LogLevel is not %v. got=%v",
logrus.InfoLevel, LogLevel)
}
}
}