@@ -32,17 +32,21 @@ func Test_ParseConfig(t *testing.T) {
32
32
})
33
33
34
34
Convey ("Applies hostnames to services" , func () {
35
- parsed , _ := disco .ParseConfig (STATIC_JSON )
35
+ parsed , err := disco .ParseConfig (STATIC_JSON )
36
+ So (err , ShouldBeNil )
37
+ So (len (parsed ), ShouldEqual , 1 )
36
38
So (parsed [0 ].Service .Hostname , ShouldEqual , hostname )
37
39
})
38
40
39
41
Convey ("Uses the given hostname when specified" , func () {
40
42
parsed , _ := disco .ParseConfig (STATIC_HOSTNAMED_JSON )
43
+ So (len (parsed ), ShouldEqual , 1 )
41
44
So (parsed [0 ].Service .Hostname , ShouldEqual , "chaucer" )
42
45
})
43
46
44
47
Convey ("Assigns the default IP address when a port doesn't have one" , func () {
45
48
parsed , _ := disco .ParseConfig (STATIC_JSON )
49
+ So (len (parsed ), ShouldEqual , 1 )
46
50
So (parsed [0 ].Service .Ports [0 ].IP , ShouldEqual , ip )
47
51
})
48
52
})
@@ -81,17 +85,23 @@ func Test_Listeners(t *testing.T) {
81
85
Convey ("Listeners()" , t , func () {
82
86
ip := "127.0.0.1"
83
87
disco := NewStaticDiscovery (STATIC_JSON , ip )
84
- tgt1 := & Target {
85
- Service : service.Service {Name : "beowulf" , ID : "asdf" },
86
- ListenPort : 10000 ,
87
- }
88
- tgt2 := & Target {
89
- Service : service.Service {Name : "hrothgar" , ID : "abba" },
90
- ListenPort : 11000 ,
91
- }
92
- disco .Targets = []* Target {tgt1 , tgt2 }
88
+
89
+ Convey ("Loads targets from the config" , func () {
90
+ disco .Run (director .NewFreeLooper (director .ONCE , nil ))
91
+ So (len (disco .Targets ), ShouldEqual , 1 )
92
+ })
93
93
94
94
Convey ("Returns all listeners extracted from Targets" , func () {
95
+ tgt1 := & Target {
96
+ Service : service.Service {Name : "beowulf" , ID : "asdf" },
97
+ ListenPort : 10000 ,
98
+ }
99
+ tgt2 := & Target {
100
+ Service : service.Service {Name : "hrothgar" , ID : "abba" },
101
+ ListenPort : 11000 ,
102
+ }
103
+ disco .Targets = []* Target {tgt1 , tgt2 }
104
+
95
105
listeners := disco .Listeners ()
96
106
97
107
expected0 := ChangeListener {
0 commit comments