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

Function assertQueryStats

proxy/stats_test.go:238–256  ·  view source on GitHub ↗

assertQueryStats asserts the statistics using the provided parameters.

(
	tb testing.TB,
	stats *proxy.QueryStatistics,
	wantMainCount int,
	wantMainErr assert.BoolAssertionFunc,
	wantFallbackCount int,
	wantFallbackErr assert.BoolAssertionFunc,
)

Source from the content-addressed store, hash-verified

236
237// assertQueryStats asserts the statistics using the provided parameters.
238func assertQueryStats(
239 tb testing.TB,
240 stats *proxy.QueryStatistics,
241 wantMainCount int,
242 wantMainErr assert.BoolAssertionFunc,
243 wantFallbackCount int,
244 wantFallbackErr assert.BoolAssertionFunc,
245) {
246 tb.Helper()
247
248 main := stats.Main()
249 assert.Lenf(tb, main, wantMainCount, "main stats count")
250
251 fallback := stats.Fallback()
252 assert.Lenf(tb, fallback, wantFallbackCount, "fallback stats count")
253
254 wantMainErr(tb, isErrorInStats(main), "main err")
255 wantFallbackErr(tb, isErrorInStats(fallback), "fallback err")
256}
257
258// isErrorInStats is a helper function for tests that returns true if the
259// upstream statistics contain an DNS lookup error.

Callers 1

TestCollectQueryStatsFunction · 0.85

Calls 3

isErrorInStatsFunction · 0.85
MainMethod · 0.80
FallbackMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…