MCPcopy
hub / github.com/coredns/coredns / TestResponse

Function TestResponse

plugin/cache/spoof_test.go:42–56  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

40}
41
42func TestResponse(t *testing.T) {
43 // Send query for example.org, get reply for example.net; should not be cached.
44 c := New()
45 c.Next = spoofHandler(false)
46
47 req := new(dns.Msg)
48 req.SetQuestion("example.net.", dns.TypeA)
49 rec := dnstest.NewRecorder(&test.ResponseWriter{})
50
51 c.ServeDNS(context.TODO(), rec, req)
52
53 if c.pcache.Len() != 0 {
54 t.Errorf("Cached %s, while reply had response set to %t", "example.net.", rec.Msg.Response)
55 }
56}
57
58// spoofHandler is a fake plugin implementation which returns a single A records for example.org. The qname in the
59// question section is set to example.NET (i.e. they *don't* match).

Callers

nothing calls this directly

Calls 6

NewRecorderFunction · 0.92
spoofHandlerFunction · 0.85
NewFunction · 0.70
ServeDNSMethod · 0.65
ErrorfMethod · 0.65
LenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…