Skip to content

Commit 52fa9c1

Browse files
committed
tests: fix backpressure tests
1 parent cd957aa commit 52fa9c1

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

test/compression.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,11 @@ describe('compression()', function () {
162162
var resp
163163
var server = createServer({ threshold: 0 }, function (req, res) {
164164
resp = res
165+
165166
res.on('drain', function () {
166167
drained = true
167168
})
169+
168170
res.setHeader('Content-Type', 'text/plain')
169171
res.write('start')
170172
pressure()
@@ -179,21 +181,23 @@ describe('compression()', function () {
179181

180182
function complete () {
181183
if (--wait !== 0) return
182-
assert.ok(drained)
183184
done()
184185
}
185186

186187
function pressure () {
187188
if (!buf || !resp || !client) return
188189

190+
assert.ok(!drained)
191+
189192
while (resp.write(buf) !== false) {
190193
resp.flush()
191194
}
192195

193196
resp.on('drain', function () {
194-
resp.write('end')
197+
assert.ok(resp.write('end'))
195198
resp.end()
196199
})
200+
197201
resp.on('finish', complete)
198202
client.resume()
199203
}
@@ -218,9 +222,11 @@ describe('compression()', function () {
218222
var resp
219223
var server = createServer({ filter: function () { return false } }, function (req, res) {
220224
resp = res
225+
221226
res.on('drain', function () {
222227
drained = true
223228
})
229+
224230
res.setHeader('Content-Type', 'text/plain')
225231
res.write('start')
226232
pressure()
@@ -235,7 +241,6 @@ describe('compression()', function () {
235241

236242
function complete () {
237243
if (--wait !== 0) return
238-
assert.ok(drained)
239244
done()
240245
}
241246

@@ -247,7 +252,8 @@ describe('compression()', function () {
247252
}
248253

249254
resp.on('drain', function () {
250-
resp.write('end')
255+
assert.ok(drained)
256+
assert.ok(resp.write('end'))
251257
resp.end()
252258
})
253259
resp.on('finish', complete)

0 commit comments

Comments
 (0)