Skip to content

Commit

Permalink
Fix flaky test again
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickjuchli committed Jul 16, 2022
1 parent f4445b0 commit 9bd6aa7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions test/uploadSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ describe("Upload", function() {
})

it(`switches correctly between sockets to track timeout during transfer`, () => {
this.client.ftp.timeout = TIMEOUT
const readable = new Readable()
readable._read = () => {}
readable.push(SHORT_TEXT)
assert.strictEqual(this.client.ftp.socket.timeout, 0, "before task (control)");
assert.strictEqual(this.client.ftp.dataSocket, undefined, "before task (data)");
this.server.addHandlers({
Expand All @@ -106,12 +108,14 @@ describe("Upload", function() {
this.server.didStartTransfer = () => {
assert.strictEqual(this.client.ftp.socket.timeout, 0, "did start transfer (control)");
assert.strictEqual(this.client.ftp.dataSocket.timeout, TIMEOUT, "did start transfer (data)");
readable.push(SHORT_TEXT)
readable.push(null)
}
this.server.didCloseDataConn = () => {
assert.strictEqual(this.client.ftp.socket.timeout, TIMEOUT, "did close data connection (control)");
assert.strictEqual(this.client.ftp.dataSocket.timeout, 0, "did close data connection (data)");
}
return this.client.uploadFrom(getReadable(VERY_LONG_TEXT), FILENAME).then(() => {
return this.client.uploadFrom(readable, FILENAME).then(() => {
assert.strictEqual(this.client.ftp.socket.timeout, 0, "after task (control)");
assert.strictEqual(this.client.ftp.dataSocket, undefined, "after task (data)");
})
Expand Down

0 comments on commit 9bd6aa7

Please sign in to comment.