Browse Source

Add some basic tests

Ask Bjørn Hansen 13 years ago
parent
commit
f783056410
2 changed files with 64 additions and 0 deletions
  1. 23 0
      config_test.go
  2. 41 0
      dns/example.com.json

+ 23 - 0
config_test.go

@@ -0,0 +1,23 @@
+package main
+
+import (
+	. "launchpad.net/gocheck"
+	"testing"
+)
+
+// Hook up gocheck into the gotest runner.
+func Test(t *testing.T) { TestingT(t) }
+
+type ConfigSuite struct {
+	zones Zones
+}
+
+var _ = Suite(&ConfigSuite{})
+
+func (s *ConfigSuite) TestReadConfigs(c *C) {
+	s.zones = make(Zones)
+	configReadDir("dns", s.zones)
+	c.Check(s.zones["example.com"].Origin, Equals, "example.com")
+	c.Check(s.zones["example.com"].Options.MaxHosts, Equals, 2)
+	c.Check(s.zones["example.com"].Labels["weight"].MaxHosts, Equals, 1)
+}

+ 41 - 0
dns/example.com.json

@@ -0,0 +1,41 @@
+{ "serial": 3,
+  "ttl":    600,
+  "max_hosts": 2,
+  "data" : {
+    "":  { "ns": { "ns1.example.net.": null, "ns2.example.net.": null } },
+    "foo": { 
+      "a": [ [ "192.168.1.2", 10 ], [ "192.168.1.3", 10 ], [ "192.168.1.4", 10 ] ],
+      "aaaa": [ ["fd06:c1d3:e902::2", 10], ["fd06:c1d3:e902:202:a5ff:fecd:13a6:a", 10], ["fd06:c1d3:e902::4", 10] ]
+    },
+    "weight": { 
+      "a": [ [ "192.168.1.2", 100 ], [ "192.168.1.3", 50 ], [ "192.168.1.4", 25 ] ],
+      "max_hosts": "1"
+    },
+    "bar": { 
+      "a": [ [ "192.168.1.2", 10 ] ],
+      "ttl": "601"
+    },
+    "0": {
+      "a": [ [ "192.168.0.1", 10 ] ]
+    },
+    "0-alias": {
+      "alias": "0"
+    },
+    "bar-alias": {
+      "alias": "bar"
+    },
+    "www-alias": {
+      "alias": "www"
+    },
+    "www": {
+      "cname": "geo.bitnames.com."
+    },
+    "cname-long-ttl": {
+      "cname": "geo.bitnames.com.",
+      "ttl": 86400
+    },
+    "cname-internal-referal": {
+      "cname": "bar"      
+    }
+  }
+}