example_test.go 559 B

1234567891011121314151617181920212223242526272829
  1. package example
  2. import (
  3. "bytes"
  4. "testing"
  5. "github.com/coredns/coredns/plugin/pkg/dnstest"
  6. "github.com/coredns/coredns/plugin/test"
  7. "github.com/miekg/dns"
  8. "golang.org/x/net/context"
  9. )
  10. func TestExample(t *testing.T) {
  11. ex := Example{Next: test.ErrorHandler()}
  12. b := &bytes.Buffer{}
  13. out = b
  14. ctx := context.TODO()
  15. r := new(dns.Msg)
  16. r.SetQuestion("example.org.", dns.TypeA)
  17. rec := dnstest.NewRecorder(&test.ResponseWriter{})
  18. ex.ServeDNS(ctx, rec, r)
  19. if x := b.String(); x != "example" {
  20. t.Errorf("Failed to print 'example', got %s", x)
  21. }
  22. }