@@ -27,70 +27,65 @@ func TestCheckDns(t *testing.T) {
27
27
args []string
28
28
want_status checkers.Status
29
29
want_msg string
30
- local_only bool
31
30
}{
32
31
{
33
32
[]string {"-H" , "example.com" },
34
33
checkers .OK ,
35
34
"status: NOERROR" ,
36
- true ,
37
35
},
38
36
{
39
37
[]string {"-H" , "example.com" , "--norec" },
40
38
checkers .OK ,
41
39
"status: NOERROR" ,
42
- true ,
43
40
},
44
41
{
45
42
[]string {"-H" , "exampleeeee.com" },
46
43
checkers .CRITICAL ,
47
44
"status: NXDOMAIN" ,
48
- true ,
49
45
},
50
46
{
51
47
[]string {"-H" , "example.com" , "-s" , "8.8.8.8" },
52
48
checkers .OK ,
53
49
"status: NOERROR" ,
54
- false ,
55
50
},
56
51
{
57
52
[]string {"-H" , "exampleeeee.com" , "-s" , "8.8.8.8" },
58
53
checkers .CRITICAL ,
59
54
"status: NXDOMAIN" ,
60
- false ,
55
+ },
56
+ {
57
+ []string {"-H" , "exampleeeee.com" , "-s" , "8.8.8" },
58
+ checkers .CRITICAL ,
59
+ "timeout" ,
61
60
},
62
61
{
63
62
[]string {"-H" , "jprs.co.jp" , "-s" , "202.11.16.49" , "--norec" },
64
63
checkers .OK ,
65
64
"status: NOERROR" ,
66
- false ,
67
65
},
68
66
{
69
67
[]string {"-H" , "www.google.com" , "-s" , "202.11.16.49" , "--norec" },
70
68
checkers .CRITICAL ,
71
69
"status: REFUSED" ,
72
- false ,
73
70
},
74
71
}
75
72
76
73
for i , tt := range tests {
77
74
t .Logf ("=== Start #%d" , i )
78
- // when runs without setting server in CI, status will be REFUSED
79
- if tt .local_only && os .Getenv ("RUN_TEST_ON_GITHUB_ACTIONS" ) == "1" {
80
- continue
81
- }
82
75
opts , err := parseArgs (tt .args )
83
76
if err != nil {
84
77
t .Fatal (err )
85
78
}
79
+ // when runs without setting server in CI, status will be REFUSED
80
+ if opts .Server == "" && os .Getenv ("RUN_TEST_ON_GITHUB_ACTIONS" ) == "1" {
81
+ continue
82
+ }
86
83
ckr := opts .run ()
87
84
88
85
assert .Equal (t , tt .want_status , ckr .Status )
89
86
90
- if tt .want_msg != "" {
91
- if ! strings .Contains (ckr .Message , tt .want_msg ) {
92
- t .Errorf ("%s is not incleded in message" , tt .want_msg )
93
- }
87
+ if ! strings .Contains (ckr .Message , tt .want_msg ) {
88
+ t .Errorf ("%s is not incleded in message" , tt .want_msg )
94
89
}
95
90
}
96
91
}
0 commit comments