MCPcopy
hub / github.com/AdguardTeam/dnsproxy / isCachedWithCustomConfig

Function isCachedWithCustomConfig

proxy/proxy_test.go:40–63  ·  view source on GitHub ↗

isCachedWithCustomConfig is a helper function that returns the caching results of a constructed request using the provided custom upstream configuration and FQDN.

(
	tb testing.TB,
	p *proxy.Proxy,
	conf *proxy.CustomUpstreamConfig,
	fqdn string,
)

Source from the content-addressed store, hash-verified

38// results of a constructed request using the provided custom upstream
39// configuration and FQDN.
40func isCachedWithCustomConfig(
41 tb testing.TB,
42 p *proxy.Proxy,
43 conf *proxy.CustomUpstreamConfig,
44 fqdn string,
45) (isCached bool) {
46 tb.Helper()
47
48 d := &proxy.DNSContext{
49 CustomUpstreamConfig: conf,
50 Req: (&dns.Msg{}).SetQuestion(fqdn, dns.TypeA),
51 }
52
53 err := p.Resolve(testutil.ContextWithTimeout(tb, defaultTimeout), d)
54 require.NoError(tb, err)
55
56 qs := d.QueryStatistics()
57 require.NotNil(tb, qs)
58
59 s := qs.Main()
60 require.Len(tb, s, 1)
61
62 return s[0].IsCached
63}
64
65func TestProxy_Resolve_cache(t *testing.T) {
66 const host = "example.test."

Callers 1

TestProxy_Resolve_cacheFunction · 0.85

Calls 3

QueryStatisticsMethod · 0.95
ResolveMethod · 0.80
MainMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…