forked from abh/geodns-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnodes_test.go
41 lines (32 loc) · 836 Bytes
/
nodes_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
package dnsconfig
import (
. "launchpad.net/gocheck"
"net"
)
type NodesSuite struct {
Nodes Nodes
}
var _ = Suite(&NodesSuite{})
func (s *NodesSuite) SetUpSuite(c *C) {
s.Nodes = NewNodes()
}
func (s *NodesSuite) TestNodes(c *C) {
s.Nodes.Clear()
s.Nodes.Set("foo", Node{Ip: net.ParseIP("10.0.0.1"), Active: true})
c.Assert(s.Nodes.Count(), Equals, 1)
node := s.Nodes.Get("foo")
c.Assert(node, NotNil)
c.Assert(node.Name, Equals, "foo")
}
func (s *NodesSuite) TestLoad(c *C) {
s.Nodes.Clear()
err := s.Nodes.LoadFile("testdata/nodes-small.json")
c.Assert(err, IsNil)
node := s.Nodes.Get("edge01.lax")
c.Assert(node, NotNil)
c.Assert(node.Ip.String(), Equals, "108.161.187.3")
c.Assert(node.Active, Equals, true)
node = s.Nodes.Get("edge01.sea")
c.Assert(node, NotNil)
c.Assert(node.Active, Equals, false)
}