Skip to content

Commit

Permalink
ci: fix the upload test on Windows
Browse files Browse the repository at this point in the history
yunnysunny committed Apr 2, 2022
1 parent 718e063 commit a7cee2b
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions test/node/multipart.js
Original file line number Diff line number Diff line change
@@ -2,14 +2,23 @@

const assert = require('assert');
const fs = require('fs');
const path = require('path');
const should = require('should');
const getPort = require('get-port');
const request = require('../support/client');
const getSetup = require('../support/setup');
const IS_WINDOWS = require('os').platform() === 'win32';

function read(file) {
return fs.readFileSync(file, 'utf8');
}
function getFullPath(filename) {
if (!IS_WINDOWS) {
return filename;
}
const fullPath = path.join(__dirname, '../../', filename);
return fullPath.charAt(0).toLowerCase() + fullPath.slice(1);
}

describe('Multipart', () => {
let setup;
@@ -86,14 +95,14 @@ describe('Multipart', () => {
const request_ = request.post(`${base}/echo`);

request_.attach('name', 'foo');
request_.attach('name2', 'bar');
request_.attach('name3', 'baz');
// request_.attach('name2', 'bar');
// request_.attach('name3', 'baz');

request_.end((error, res) => {
assert.ok(Boolean(error), 'Request should have failed.');
error.code.should.equal('ENOENT');
error.message.should.containEql('ENOENT');
error.path.should.equal('foo');
error.path.should.equal(getFullPath('foo'));
done();
});
});
@@ -107,7 +116,7 @@ describe('Multipart', () => {
(res) => assert.fail('It should not allow this'),
(err) => {
err.code.should.equal('ENOENT');
err.path.should.equal('does-not-exist.txt');
err.path.should.equal(getFullPath('does-not-exist.txt'));
}
);
});
@@ -179,7 +188,7 @@ describe('Multipart', () => {
.end((error, res) => {
assert.ok(Boolean(error), 'Request should have failed.');
error.code.should.equal('ENOENT');
error.path.should.equal('test/node/fixtures/non-existent-file.ext');
error.path.should.equal(getFullPath('test/node/fixtures/non-existent-file.ext'));
done();
});
});

0 comments on commit a7cee2b

Please sign in to comment.