Переглянути джерело

Move configuration for tests to test.example.com

Ask Bjørn Hansen 13 роки тому
батько
коміт
c11faa4909
3 змінених файлів з 59 додано та 5 видалено
  1. 8 2
      config_test.go
  2. 48 0
      dns/test.example.com.json
  3. 3 3
      serve_test.go

+ 8 - 2
config_test.go

@@ -17,7 +17,13 @@ var _ = Suite(&ConfigSuite{})
 func (s *ConfigSuite) TestReadConfigs(c *C) {
 	s.zones = make(Zones)
 	configReadDir("dns", s.zones)
+
+	// Just check that example.com loaded, too.
 	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)
+
+	// The real tests are in test.example.com so we have a place
+	// to make nutty configuration entries
+	c.Check(s.zones["test.example.com"].Origin, Equals, "test.example.com")
+	c.Check(s.zones["test.example.com"].Options.MaxHosts, Equals, 2)
+	c.Check(s.zones["test.example.com"].Labels["weight"].MaxHosts, Equals, 1)
 }

+ 48 - 0
dns/test.example.com.json

@@ -0,0 +1,48 @@
+{ "serial": 3,
+  "ttl":    600,
+  "max_hosts": 2,
+  "data" : {
+    "":  {
+      "ns": { "ns1.example.net.": null, "ns2.example.net.": null },
+      "mx": [ { "preference": 20, "mx": "mx2.example.net", "weight": 0 },
+              { "preference": 10, "mx": "mx.example.net.", "weight": 1 }
+            ]
+    },
+    "europe": { "mx": [ { "mx": "mx-eu.example.net" }]},
+    "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"
+    },
+    "bar.no": { "a": [] },
+    "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"      
+    }
+  }
+}

+ 3 - 3
serve_test.go

@@ -23,17 +23,17 @@ func (s *ConfigSuite) TestServing(c *C) {
 		c.Fail()
 	}
 
-	r = exchange(c, "bar.example.com.", dns.TypeA)
+	r = exchange(c, "bar.test.example.com.", dns.TypeA)
 	ip := r.Answer[0].(*dns.RR_A).A
 	c.Check(ip.String(), Equals, "192.168.1.2")
 
-	r = exchange(c, "example.com.", dns.TypeSOA)
+	r = exchange(c, "test.example.com.", dns.TypeSOA)
 	soa := r.Answer[0].(*dns.RR_SOA)
 	serial := soa.Serial
 	c.Check(int(serial), Equals, 3)
 
 	// no AAAA records for 'bar', so check we get a soa record back
-	r = exchange(c, "example.com.", dns.TypeAAAA)
+	r = exchange(c, "test.example.com.", dns.TypeAAAA)
 	soa2 := r.Ns[0].(*dns.RR_SOA)
 	c.Check(soa, DeepEquals, soa2)
 }