-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgeomap_test.go
45 lines (32 loc) · 1.15 KB
/
geomap_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
package dnsconfig
import (
. "launchpad.net/gocheck"
)
type GeoMapSuite struct {
GeoMap GeoMap
}
var _ = Suite(&GeoMapSuite{})
func (s *GeoMapSuite) SetUpSuite(c *C) {
s.GeoMap = NewGeoMap()
}
func (s *GeoMapSuite) TestGeoMap(c *C) {
s.GeoMap.Clear()
}
func (s *GeoMapSuite) TestGeoLoad(c *C) {
s.GeoMap.Clear()
err := s.GeoMap.LoadFile("testdata/geomap.json")
c.Assert(err, IsNil)
// results are sorted appropriately
c.Assert(s.GeoMap.geomap["*.ams*"][0].target, Equals, "fr")
c.Assert(s.GeoMap.geomap["*.ams*"][1].target, Equals, "nl")
c.Assert(s.GeoMap.geomap["*.ams*"][2].target, Equals, "europe")
// "@" gets sorted first
c.Assert(s.GeoMap.GetNodeGeos("test.sea")[0].target, Equals, "@")
c.Assert(s.GeoMap.geomap["*.lhr"][1].weight, Equals, 1000)
// make sure we get the more specific entry
c.Assert(s.GeoMap.GetNodeGeos("flex04.ams04")[0].weight, Equals, 1)
c.Assert(s.GeoMap.GetNodeGeos("flex04.ams04")[0].target, Equals, "europe")
c.Assert(s.GeoMap.GetNodeGeos("x123.lhr")[1].weight, Equals, 1000)
c.Assert(s.GeoMap.GetNodeGeos("x123.lhr")[1].target, Equals, "europe")
c.Assert(s.GeoMap.GetNodeGeos("x123.lhr")[0].weight, Equals, 100)
}