-
Notifications
You must be signed in to change notification settings - Fork 10
/
config_test.go
46 lines (40 loc) · 1.24 KB
/
config_test.go
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
39
40
41
42
43
44
45
46
package gubernator
import (
"fmt"
"os"
"strings"
"testing"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
)
func TestParsesGrpcAddress(t *testing.T) {
os.Clearenv()
s := `
# a comment
GUBER_GRPC_ADDRESS=10.10.10.10:9000`
daemonConfig, err := SetupDaemonConfig(logrus.StandardLogger(), strings.NewReader(s))
require.NoError(t, err)
require.Equal(t, "10.10.10.10:9000", daemonConfig.GRPCListenAddress)
require.NotEmpty(t, daemonConfig.InstanceID)
}
func TestDefaultListenAddress(t *testing.T) {
os.Clearenv()
s := `
# a comment`
daemonConfig, err := SetupDaemonConfig(logrus.StandardLogger(), strings.NewReader(s))
require.NoError(t, err)
require.Equal(t, fmt.Sprintf("%s:1051", LocalHost()), daemonConfig.GRPCListenAddress)
require.Equal(t, fmt.Sprintf("%s:1050", LocalHost()), daemonConfig.HTTPListenAddress)
require.NotEmpty(t, daemonConfig.InstanceID)
}
func TestDefaultInstanceId(t *testing.T) {
os.Clearenv()
s := ``
daemonConfig, err := SetupDaemonConfig(logrus.StandardLogger(), strings.NewReader(s))
require.NoError(t, err)
require.NotEmpty(t, daemonConfig.InstanceID)
instanceConfig := Config{}
err = instanceConfig.SetDefaults()
require.NoError(t, err)
require.NotEmpty(t, instanceConfig.InstanceID)
}