99)
1010
1111var servers = []string {"8.8.8.8" }
12- var domains = []string {"mjasion.pl " }
12+ var domains = []string {"google.com " }
1313
1414func TestGathering (t * testing.T ) {
1515 var dnsConfig = DnsQuery {
@@ -18,8 +18,10 @@ func TestGathering(t *testing.T) {
1818 }
1919 var acc testutil.Accumulator
2020
21- dnsConfig .Gather (& acc )
22- metric , _ := acc .Get ("dns_query" )
21+ err := dnsConfig .Gather (& acc )
22+ assert .NoError (t , err )
23+ metric , ok := acc .Get ("dns_query" )
24+ assert .True (t , ok )
2325 queryTime , _ := metric .Fields ["query_time_ms" ].(float64 )
2426
2527 assert .NotEqual (t , 0 , queryTime )
@@ -33,8 +35,10 @@ func TestGatheringMxRecord(t *testing.T) {
3335 var acc testutil.Accumulator
3436 dnsConfig .RecordType = "MX"
3537
36- dnsConfig .Gather (& acc )
37- metric , _ := acc .Get ("dns_query" )
38+ err := dnsConfig .Gather (& acc )
39+ assert .NoError (t , err )
40+ metric , ok := acc .Get ("dns_query" )
41+ assert .True (t , ok )
3842 queryTime , _ := metric .Fields ["query_time_ms" ].(float64 )
3943
4044 assert .NotEqual (t , 0 , queryTime )
@@ -54,8 +58,10 @@ func TestGatheringRootDomain(t *testing.T) {
5458 }
5559 fields := map [string ]interface {}{}
5660
57- dnsConfig .Gather (& acc )
58- metric , _ := acc .Get ("dns_query" )
61+ err := dnsConfig .Gather (& acc )
62+ assert .NoError (t , err )
63+ metric , ok := acc .Get ("dns_query" )
64+ assert .True (t , ok )
5965 queryTime , _ := metric .Fields ["query_time_ms" ].(float64 )
6066
6167 fields ["query_time_ms" ] = queryTime
@@ -70,13 +76,15 @@ func TestMetricContainsServerAndDomainAndRecordTypeTags(t *testing.T) {
7076 var acc testutil.Accumulator
7177 tags := map [string ]string {
7278 "server" : "8.8.8.8" ,
73- "domain" : "mjasion.pl " ,
79+ "domain" : "google.com " ,
7480 "record_type" : "NS" ,
7581 }
7682 fields := map [string ]interface {}{}
7783
78- dnsConfig .Gather (& acc )
79- metric , _ := acc .Get ("dns_query" )
84+ err := dnsConfig .Gather (& acc )
85+ assert .NoError (t , err )
86+ metric , ok := acc .Get ("dns_query" )
87+ assert .True (t , ok )
8088 queryTime , _ := metric .Fields ["query_time_ms" ].(float64 )
8189
8290 fields ["query_time_ms" ] = queryTime
0 commit comments