@@ -26,47 +26,67 @@ func TestCheckDns(t *testing.T) {
26
26
tests := []struct {
27
27
args []string
28
28
want_status checkers.Status
29
- want_msg string
29
+ want_msg [] string
30
30
}{
31
31
{
32
32
[]string {"-H" , "example.com" },
33
33
checkers .OK ,
34
- "status: NOERROR" ,
34
+ [] string { "status: NOERROR" } ,
35
35
},
36
36
{
37
37
[]string {"-H" , "example.com" , "--norec" },
38
38
checkers .OK ,
39
- "status: NOERROR" ,
39
+ [] string { "status: NOERROR" } ,
40
40
},
41
41
{
42
42
[]string {"-H" , "exampleeeee.com" },
43
43
checkers .CRITICAL ,
44
- "status: NXDOMAIN" ,
44
+ [] string { "status: NXDOMAIN" } ,
45
45
},
46
46
{
47
47
[]string {"-H" , "example.com" , "-s" , "8.8.8.8" },
48
48
checkers .OK ,
49
- "status: NOERROR" ,
49
+ [] string { "status: NOERROR" } ,
50
50
},
51
51
{
52
52
[]string {"-H" , "exampleeeee.com" , "-s" , "8.8.8.8" },
53
53
checkers .CRITICAL ,
54
- "status: NXDOMAIN" ,
54
+ [] string { "status: NXDOMAIN" } ,
55
55
},
56
56
{
57
57
[]string {"-H" , "exampleeeee.com" , "-s" , "8.8.8" },
58
58
checkers .CRITICAL ,
59
- "timeout" ,
59
+ [] string { "timeout" } ,
60
60
},
61
61
{
62
62
[]string {"-H" , "jprs.co.jp" , "-s" , "202.11.16.49" , "--norec" },
63
63
checkers .OK ,
64
- "status: NOERROR" ,
64
+ [] string { "status: NOERROR" } ,
65
65
},
66
66
{
67
67
[]string {"-H" , "www.google.com" , "-s" , "202.11.16.49" , "--norec" },
68
68
checkers .CRITICAL ,
69
- "status: REFUSED" ,
69
+ []string {"status: REFUSED" },
70
+ },
71
+ {
72
+ []string {"-H" , "example.com" , "-s" , "8.8.8.8" , "-q" , "AAAA" },
73
+ checkers .OK ,
74
+ []string {"status: NOERROR" , "AAAA" },
75
+ },
76
+ {
77
+ []string {"-H" , "example.com" , "-s" , "8.8.8.8" , "-q" , "AAA" },
78
+ checkers .CRITICAL ,
79
+ []string {"AAA is invalid queryType" },
80
+ },
81
+ {
82
+ []string {"-H" , "example.com" , "-s" , "8.8.8.8" , "-c" , "IN" },
83
+ checkers .OK ,
84
+ []string {"status: NOERROR" },
85
+ },
86
+ {
87
+ []string {"-H" , "example.com" , "-s" , "8.8.8.8" , "-c" , "INN" },
88
+ checkers .CRITICAL ,
89
+ []string {"INN is invalid queryClass" },
70
90
},
71
91
}
72
92
@@ -84,8 +104,10 @@ func TestCheckDns(t *testing.T) {
84
104
85
105
assert .Equal (t , tt .want_status , ckr .Status )
86
106
87
- if ! strings .Contains (ckr .Message , tt .want_msg ) {
88
- t .Errorf ("%s is not incleded in message" , tt .want_msg )
107
+ for _ , want := range tt .want_msg {
108
+ if ! strings .Contains (ckr .Message , want ) {
109
+ t .Errorf ("%s is not incleded in message" , want )
110
+ }
89
111
}
90
112
}
91
113
}
0 commit comments