config_test.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package main
  2. import (
  3. "github.com/miekg/dns"
  4. . "launchpad.net/gocheck"
  5. "testing"
  6. )
  7. // Hook up gocheck into the gotest runner.
  8. func Test(t *testing.T) { TestingT(t) }
  9. type ConfigSuite struct {
  10. zones Zones
  11. }
  12. var _ = Suite(&ConfigSuite{})
  13. func (s *ConfigSuite) TestReadConfigs(c *C) {
  14. s.zones = make(Zones)
  15. configReadDir("dns", s.zones)
  16. // Just check that example.com loaded, too.
  17. c.Check(s.zones["example.com"].Origin, Equals, "example.com")
  18. tz := s.zones["test.example.com"]
  19. // The real tests are in test.example.com so we have a place
  20. // to make nutty configuration entries
  21. c.Check(tz.Origin, Equals, "test.example.com")
  22. c.Check(tz.Options.MaxHosts, Equals, 2)
  23. c.Check(tz.Options.Contact, Equals, "support.bitnames.com")
  24. c.Check(tz.Labels["weight"].MaxHosts, Equals, 1)
  25. /* test different cname targets */
  26. c.Check(tz.Labels["www"].
  27. firstRR(dns.TypeCNAME).(*dns.CNAME).
  28. Target, Equals, "geo.bitnames.com.")
  29. c.Check(tz.Labels["www-cname"].
  30. firstRR(dns.TypeCNAME).(*dns.CNAME).
  31. Target, Equals, "bar.test.example.com.")
  32. c.Check(tz.Labels["www-alias"].
  33. firstRR(dns.TypeCNAME).(*dns.CNAME).
  34. Target, Equals, "bar-alias.test.example.com.")
  35. }