mirror of
https://github.com/linka-cloud/coredns-split.git
synced 2024-11-16 09:46:24 +00:00
28 lines
723 B
Go
28 lines
723 B
Go
package split
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/coredns/coredns/plugin/pkg/dnstest"
|
|
"github.com/coredns/coredns/plugin/test"
|
|
|
|
"github.com/miekg/dns"
|
|
)
|
|
|
|
func TestExample(t *testing.T) {
|
|
// Create a new Split Plugin. Use the test.ErrorHandler as the next plugin.
|
|
x := Split{Next: test.ErrorHandler()}
|
|
|
|
ctx := context.TODO()
|
|
r := new(dns.Msg)
|
|
r.SetQuestion("example.org.", dns.TypeA)
|
|
// Create a new Recorder that captures the result, this isn't actually used in this test
|
|
// as it just serves as something that implements the dns.ResponseWriter interface.
|
|
rec := dnstest.NewRecorder(&test.ResponseWriter{})
|
|
|
|
// Call our plugin directly, and check the result.
|
|
x.ServeDNS(ctx, rec, r)
|
|
t.Log(rec.Msg)
|
|
}
|