Skip to content

Commit

Permalink
Make tests run on Node 8
Browse files Browse the repository at this point in the history
  • Loading branch information
zbynek committed Jul 3, 2021
1 parent 0e717e2 commit b20fd41
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions test/main.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const test = require('tap').test;
const path = require('path');
const fs = require('fs').promises;
const fs = require('fs');
const request = require('request');
const httpServer = require('../lib/http-server');
const promisify = require('util').promisify;

const requestAsync = promisify(request);
const fsReadFile = promisify(fs.readFile);

// Prevent errors from being swallowed
process.on('uncaughtException', console.error);
Expand Down Expand Up @@ -42,7 +43,7 @@ test('http-server main', (t) => {
// files should be served from the root
t.equal(res.statusCode, 200);

const fileData = await fs.readFile(path.join(root, 'file'), 'utf8');
const fileData = await fsReadFile(path.join(root, 'file'), 'utf8');
t.equal(res.body.trim(), fileData.trim(), 'root file content matches');
}).catch(err => t.fail(err.toString())),

Expand Down Expand Up @@ -129,7 +130,7 @@ test('http-server main', (t) => {
t.equal(res.statusCode, 200);

// File content matches
const fileData = await fs.readFile(path.join(root, 'file'), 'utf8');
const fileData = await fsReadFile(path.join(root, 'file'), 'utf8');
t.equal(res.body.trim(), fileData.trim(), 'proxied root file content matches');
}).catch(err => t.fail(err.toString()));

Expand All @@ -139,7 +140,7 @@ test('http-server main', (t) => {
t.equal(res.statusCode, 200);

// File content matches
const fileData = await fs.readFile(path.join(root, 'file'), 'utf8');
const fileData = await fsReadFile(path.join(root, 'file'), 'utf8');
t.equal(res.body.trim(), fileData.trim(), 'proxy fallback root file content matches');
}).catch(err => t.fail(err.toString()));
} catch (err) {
Expand Down Expand Up @@ -216,7 +217,7 @@ test('http-server main', (t) => {
}
}).then(async (res) => {
t.equal(res.statusCode, 200);
const fileData = await fs.readFile(path.join(root, 'file'), 'utf8');
const fileData = await fsReadFile(path.join(root, 'file'), 'utf8');
t.equal(res.body.trim(), fileData.trim(), 'auth-protected file with good auth has expected file content');
}).catch(err => t.fail(err.toString())),
]);
Expand Down Expand Up @@ -265,7 +266,7 @@ test('http-server main', (t) => {
}
}).then(async (res) => {
t.equal(res.statusCode, 200);
const fileData = await fs.readFile(path.join(root, 'file'), 'utf8');
const fileData = await fsReadFile(path.join(root, 'file'), 'utf8');
t.equal(res.body.trim(), fileData.trim(), 'numeric auth with good auth has expected file content');
}).catch(err => t.fail(err.toString()))
]);
Expand Down

0 comments on commit b20fd41

Please sign in to comment.