@@ -5,7 +5,7 @@ const assert = require('assert');
5
5
const dns = require ( 'dns' ) ;
6
6
7
7
const existing = dns . getServers ( ) ;
8
- assert ( existing . length ) ;
8
+ assert ( existing . length > 0 ) ;
9
9
10
10
// Verify that setServers() handles arrays with holes and other oddities
11
11
assert . doesNotThrow ( ( ) => {
@@ -42,7 +42,8 @@ const goog = [
42
42
] ;
43
43
assert . doesNotThrow ( ( ) => dns . setServers ( goog ) ) ;
44
44
assert . deepStrictEqual ( dns . getServers ( ) , goog ) ;
45
- assert . throws ( ( ) => dns . setServers ( [ 'foobar' ] ) ) ;
45
+ assert . throws ( ( ) => dns . setServers ( [ 'foobar' ] ) ,
46
+ / ^ E r r o r : I P a d d r e s s i s n o t p r o p e r l y f o r m a t t e d : f o o b a r $ / ) ;
46
47
assert . deepStrictEqual ( dns . getServers ( ) , goog ) ;
47
48
48
49
const goog6 = [
@@ -77,20 +78,18 @@ assert.throws(() => {
77
78
} , 'Unexpected error' ) ;
78
79
79
80
// dns.lookup should accept falsey and string values
80
- assert . throws ( ( ) => dns . lookup ( { } , noop ) ,
81
- 'invalid arguments: hostname must be a string or falsey' ) ;
81
+ const errorReg =
82
+ / ^ T y p e E r r o r : I n v a l i d a r g u m e n t s : h o s t n a m e m u s t b e a s t r i n g o r f a l s e y $ / ;
82
83
83
- assert . throws ( ( ) => dns . lookup ( [ ] , noop ) ,
84
- 'invalid arguments: hostname must be a string or falsey' ) ;
84
+ assert . throws ( ( ) => dns . lookup ( { } , noop ) , errorReg ) ;
85
85
86
- assert . throws ( ( ) => dns . lookup ( true , noop ) ,
87
- 'invalid arguments: hostname must be a string or falsey' ) ;
86
+ assert . throws ( ( ) => dns . lookup ( [ ] , noop ) , errorReg ) ;
88
87
89
- assert . throws ( ( ) => dns . lookup ( 1 , noop ) ,
90
- 'invalid arguments: hostname must be a string or falsey' ) ;
88
+ assert . throws ( ( ) => dns . lookup ( true , noop ) , errorReg ) ;
91
89
92
- assert . throws ( ( ) => dns . lookup ( noop , noop ) ,
93
- 'invalid arguments: hostname must be a string or falsey' ) ;
90
+ assert . throws ( ( ) => dns . lookup ( 1 , noop ) , errorReg ) ;
91
+
92
+ assert . throws ( ( ) => dns . lookup ( noop , noop ) , errorReg ) ;
94
93
95
94
assert . doesNotThrow ( ( ) => dns . lookup ( '' , noop ) ) ;
96
95
@@ -114,13 +113,13 @@ assert.doesNotThrow(() => dns.lookup(NaN, noop));
114
113
assert . throws ( ( ) => {
115
114
dns . lookup ( 'www.google.com' , { hints : ( dns . V4MAPPED | dns . ADDRCONFIG ) + 1 } ,
116
115
noop ) ;
117
- } ) ;
116
+ } , / ^ T y p e E r r o r : I n v a l i d a r g u m e n t : h i n t s m u s t u s e v a l i d f l a g s $ / ) ;
118
117
119
118
assert . throws ( ( ) => dns . lookup ( 'www.google.com' ) ,
120
- 'invalid arguments: callback must be passed' ) ;
119
+ / ^ T y p e E r r o r : I n v a l i d a r g u m e n t s : c a l l b a c k m u s t b e p a s s e d $ / ) ;
121
120
122
121
assert . throws ( ( ) => dns . lookup ( 'www.google.com' , 4 ) ,
123
- 'invalid arguments: callback must be passed' ) ;
122
+ / ^ T y p e E r r o r : I n v a l i d a r g u m e n t s : c a l l b a c k m u s t b e p a s s e d $ / ) ;
124
123
125
124
assert . doesNotThrow ( ( ) => dns . lookup ( 'www.google.com' , 6 , noop ) ) ;
126
125
@@ -143,26 +142,29 @@ assert.doesNotThrow(() => {
143
142
} , noop ) ;
144
143
} ) ;
145
144
146
- assert . throws ( ( ) => dns . lookupService ( '0.0.0.0' ) , / I n v a l i d a r g u m e n t s / ) ;
145
+ assert . throws ( ( ) => dns . lookupService ( '0.0.0.0' ) ,
146
+ / ^ E r r o r : I n v a l i d a r g u m e n t s $ / ) ;
147
147
148
148
assert . throws ( ( ) => dns . lookupService ( 'fasdfdsaf' , 0 , noop ) ,
149
- / " h o s t " a r g u m e n t n e e d s t o b e a v a l i d I P a d d r e s s / ) ;
149
+ / ^ T y p e E r r o r : " h o s t " a r g u m e n t n e e d s t o b e a v a l i d I P a d d r e s s $ / ) ;
150
150
151
151
assert . doesNotThrow ( ( ) => dns . lookupService ( '0.0.0.0' , '0' , noop ) ) ;
152
152
153
153
assert . doesNotThrow ( ( ) => dns . lookupService ( '0.0.0.0' , 0 , noop ) ) ;
154
154
155
155
assert . throws ( ( ) => dns . lookupService ( '0.0.0.0' , null , noop ) ,
156
- / " p o r t " s h o u l d b e > = 0 a n d < 6 5 5 3 6 , g o t " n u l l " / ) ;
156
+ / ^ T y p e E r r o r : " p o r t " s h o u l d b e > = 0 a n d < 6 5 5 3 6 , g o t " n u l l " $ / ) ;
157
157
158
- assert . throws ( ( ) => dns . lookupService ( '0.0.0.0' , undefined , noop ) ,
159
- / " p o r t " s h o u l d b e > = 0 a n d < 6 5 5 3 6 , g o t " u n d e f i n e d " / ) ;
158
+ assert . throws (
159
+ ( ) => dns . lookupService ( '0.0.0.0' , undefined , noop ) ,
160
+ / ^ T y p e E r r o r : " p o r t " s h o u l d b e > = 0 a n d < 6 5 5 3 6 , g o t " u n d e f i n e d " $ /
161
+ ) ;
160
162
161
163
assert . throws ( ( ) => dns . lookupService ( '0.0.0.0' , 65538 , noop ) ,
162
- / " p o r t " s h o u l d b e > = 0 a n d < 6 5 5 3 6 , g o t " 6 5 5 3 8 " / ) ;
164
+ / ^ T y p e E r r o r : " p o r t " s h o u l d b e > = 0 a n d < 6 5 5 3 6 , g o t " 6 5 5 3 8 " $ / ) ;
163
165
164
166
assert . throws ( ( ) => dns . lookupService ( '0.0.0.0' , 'test' , noop ) ,
165
- / " p o r t " s h o u l d b e > = 0 a n d < 6 5 5 3 6 , g o t " t e s t " / ) ;
167
+ / ^ T y p e E r r o r : " p o r t " s h o u l d b e > = 0 a n d < 6 5 5 3 6 , g o t " t e s t " $ / ) ;
166
168
167
169
assert . throws ( ( ) => dns . lookupService ( '0.0.0.0' , 80 , null ) ,
168
170
/ ^ T y p e E r r o r : " c a l l b a c k " a r g u m e n t m u s t b e a f u n c t i o n $ / ) ;
0 commit comments