@@ -128,32 +128,41 @@ func TestRunner_countTargetFromRawTarget(t *testing.T) {
128
128
129
129
input := "example.com"
130
130
expected := 1
131
- got := r .countTargetFromRawTarget (input )
131
+ got , err := r .countTargetFromRawTarget (input )
132
+ require .Nil (t , err , "could not count targets" )
132
133
require .Equal (t , expected , got , "got wrong output" )
133
134
134
135
input = "example.com"
135
136
expected = 0
136
137
err = r .hm .Set (input , nil )
137
138
require .Nil (t , err , "could not set value to hm" )
138
- got = r .countTargetFromRawTarget (input )
139
+ got , err = r .countTargetFromRawTarget (input )
140
+ require .Nil (t , err , "could not count targets" )
141
+ require .Equal (t , expected , got , "got wrong output" )
142
+
143
+ input = "173.0.84.0/24"
144
+ expected = 256
145
+ got , err = r .countTargetFromRawTarget (input )
146
+ require .Nil (t , err , "could not count targets" )
139
147
require .Equal (t , expected , got , "got wrong output" )
140
148
141
149
input = ""
142
150
expected = 0
143
- got = r .countTargetFromRawTarget (input )
151
+ got , err = r .countTargetFromRawTarget (input )
152
+ require .Nil (t , err , "could not count targets" )
144
153
require .Equal (t , expected , got , "got wrong output" )
145
154
146
155
if os .Getenv ("PDCP_API_KEY" ) != "" {
147
156
input = "AS14421"
148
157
expected = 256
149
- got = r .countTargetFromRawTarget (input )
158
+ got , err = r .countTargetFromRawTarget (input )
159
+ if err != nil && stringsutil .ContainsAnyI (err .Error (), "unauthorized: 401" ) {
160
+ t .Skip ("skipping asn test due to missing/invalid api key" )
161
+ return
162
+ }
163
+ require .Nil (t , err , "could not count targets" )
150
164
require .Equal (t , expected , got , "got wrong output" )
151
165
}
152
-
153
- input = "173.0.84.0/24"
154
- expected = 256
155
- got = r .countTargetFromRawTarget (input )
156
- require .Equal (t , expected , got , "got wrong output" )
157
166
}
158
167
159
168
func TestRunner_urlWithComma_targets (t * testing.T ) {
0 commit comments