test: add t.Helper() calls to test helper functions (#7351)

This commit is contained in:
Ville Vesilehto
2025-06-05 00:36:04 +03:00
committed by GitHub
parent b4abdcacf0
commit 9f9aed31cf
30 changed files with 52 additions and 13 deletions

View File

@@ -56,6 +56,7 @@ func TestLookupCache(t *testing.T) {
}
func testCase(t *testing.T, name, addr string, expectAnsLen int, expectTTL uint32) {
t.Helper()
m := new(dns.Msg)
m.SetQuestion(name, dns.TypeA)
resp, err := dns.Exchange(m, addr)
@@ -74,6 +75,7 @@ func testCase(t *testing.T, name, addr string, expectAnsLen int, expectTTL uint3
}
func testCaseDNSSEC(t *testing.T, name, addr string, bufsize int) {
t.Helper()
m := new(dns.Msg)
m.SetQuestion(name, dns.TypeA)

View File

@@ -9,6 +9,7 @@ import (
)
func setupProxyTargetCoreDNS(t *testing.T, fn func(string)) {
t.Helper()
tmpdir := t.TempDir()
content := `

View File

@@ -117,6 +117,7 @@ func getBucketCount(mf *test.MetricFamily, bucketLabel string) (int, error) {
// extractRequestSizeBucketCounts extracts bucket counts from DNS request size metrics
func extractRequestSizeBucketCounts(t *testing.T, metrics []*test.MetricFamily, label string) (int, int, error) {
t.Helper()
var countBelow100, countAbove100 int
var err error

View File

@@ -55,6 +55,7 @@ func TestLookupBalanceRewriteCacheDnssec(t *testing.T) {
}
func createKeyFile(t *testing.T) func() {
t.Helper()
os.WriteFile(base+".key",
[]byte(`example.org. IN DNSKEY 256 3 13 tDyI0uEIDO4SjhTJh1AVTFBLpKhY3He5BdAlKztewiZ7GecWj94DOodg ovpN73+oJs+UfZ+p9zOSN5usGAlHrw==`),
0644)

View File

@@ -44,6 +44,7 @@ func TestReload(t *testing.T) {
}
func send(t *testing.T, server string) {
t.Helper()
m := new(dns.Msg)
m.SetQuestion("whoami.example.org.", dns.TypeSRV)

View File

@@ -57,6 +57,7 @@ func TestRewrite(t *testing.T) {
}
func testMX(t *testing.T, server string) {
t.Helper()
m := new(dns.Msg)
m.SetQuestion("example.com.", dns.TypeMX)
@@ -78,6 +79,7 @@ func testMX(t *testing.T, server string) {
}
func testEdns0(t *testing.T, server string) {
t.Helper()
m := new(dns.Msg)
m.SetQuestion("example.com.", dns.TypeA)

View File

@@ -45,6 +45,7 @@ func TestProxyToChaosServer(t *testing.T) {
}
func chaosTest(t *testing.T, server string) {
t.Helper()
m := new(dns.Msg)
m.Question = make([]dns.Question, 1)
m.Question[0] = dns.Question{Qclass: dns.ClassCHAOS, Name: "version.bind.", Qtype: dns.TypeTXT}

View File

@@ -140,6 +140,7 @@ func TestView(t *testing.T) {
}
func viewTest(t *testing.T, testName, addr, qname string, qtype uint16, expectRcode int, expectAnswers []dns.RR) {
t.Helper()
t.Run(testName, func(t *testing.T) {
m := new(dns.Msg)