Skip to content

Commit

Permalink
Merge pull request #558 from eik-lib/fix_tests_for_node_gt_16
Browse files Browse the repository at this point in the history
Fix tests for node greater than 16, upgrade Node to v20
  • Loading branch information
wkillerud authored Jul 29, 2024
2 parents 68d9b4c + 1d7b363 commit ee93a4b
Show file tree
Hide file tree
Showing 18 changed files with 91 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 16
node-version: 20

- name: Install dependencies
run: npm install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macOS-latest] #, windows-latest]
node-version: [16]
node-version: [20]

runs-on: ${{ matrix.os }}

Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16
20
5 changes: 4 additions & 1 deletion test/alias.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ beforeEach(async (t) => {
const memSink = new sink.MEM();
const service = new EikService({ customSink: memSink });
server.register(service.api());
const address = await server.listen();
const address = await server.listen({
host: '127.0.0.1',
port: 0,
});

const token = await cli.login({
server: address,
Expand Down
5 changes: 4 additions & 1 deletion test/integration/alias.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ beforeEach(async (t) => {
const memSink = new sink.MEM();
const service = new EikService({ customSink: memSink });
server.register(service.api());
const address = await server.listen();
const address = await server.listen({
host: '127.0.0.1',
port: 0,
});
const folder = await fs.mkdtemp(join(os.tmpdir(), basename(__filename)));
const eik = join(__dirname, '../../index.js');

Expand Down
5 changes: 4 additions & 1 deletion test/integration/integrity.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ beforeEach(async (t) => {
const server = fastify({ logger: false });
const service = new EikService({ customSink: memSink });
server.register(service.api());
const address = await server.listen();
const address = await server.listen({
host: '127.0.0.1',
port: 0,
});
const folder = await fs.mkdtemp(join(os.tmpdir(), basename(__filename)));

const token = await cli.login({
Expand Down
5 changes: 4 additions & 1 deletion test/integration/login.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ beforeEach(async (t) => {
const server = fastify({ logger: false });
const service = new EikService({ customSink: memSink });
server.register(service.api());
const address = await server.listen();
const address = await server.listen({
host: '127.0.0.1',
port: 0,
});

const folder = await fs.mkdtemp(join(os.tmpdir(), basename(__filename)));

Expand Down
5 changes: 4 additions & 1 deletion test/integration/map.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ beforeEach(async (t) => {
const server = fastify({ logger: false });
const service = new EikService({ customSink: memSink });
server.register(service.api());
const address = await server.listen();
const address = await server.listen({
host: '127.0.0.1',
port: 0,
});
const folder = await fs.mkdtemp(join(os.tmpdir(), basename(__filename)));

const token = await cli.login({
Expand Down
5 changes: 4 additions & 1 deletion test/integration/meta.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ beforeEach(async (t) => {
const server = fastify({ logger: false });
const service = new EikService({ customSink: memSink });
server.register(service.api());
const address = await server.listen();
const address = await server.listen({
host: '127.0.0.1',
port: 0,
});
const folder = await fs.mkdtemp(join(os.tmpdir(), basename(__filename)));
const eik = join(__dirname, '../../index.js');

Expand Down
5 changes: 4 additions & 1 deletion test/integration/package.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ beforeEach(async (t) => {
const server = fastify({ logger: false });
const service = new EikService({ customSink: memSink });
server.register(service.api());
const address = await server.listen();
const address = await server.listen({
host: '127.0.0.1',
port: 0,
});
const folder = await fs.mkdtemp(join(os.tmpdir(), basename(__filename)));

const token = await cli.login({
Expand Down
5 changes: 4 additions & 1 deletion test/integrity.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ beforeEach(async (t) => {
const memSink = new sink.MEM();
const service = new EikService({ customSink: memSink });
server.register(service.api());
const address = await server.listen();
const address = await server.listen({
host: '127.0.0.1',
port: 0,
});

const token = await cli.login({
server: address,
Expand Down
5 changes: 4 additions & 1 deletion test/login.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ beforeEach(async (t) => {
const server = fastify({ logger: false });
const service = new EikService({ customSink: memSink });
server.register(service.api());
const address = await server.listen();
const address = await server.listen({
host: '127.0.0.1',
port: 0,
});
t.context.server = server;
t.context.address = address;
});
Expand Down
5 changes: 4 additions & 1 deletion test/meta.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ beforeEach(async (t) => {
const memSink = new sink.MEM();
const service = new EikService({ customSink: memSink });
server.register(service.api());
const address = await server.listen();
const address = await server.listen({
host: '127.0.0.1',
port: 0,
});

const token = await cli.login({
server: address,
Expand Down
5 changes: 4 additions & 1 deletion test/publish-files-definitions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ beforeEach(async (t) => {
const server = fastify({ logger: false });
const service = new EikService({ customSink: memSink });
server.register(service.api());
const address = await server.listen();
const address = await server.listen({
host: '127.0.0.1',
port: 0,
});

const token = await cli.login({
server: address,
Expand Down
5 changes: 4 additions & 1 deletion test/publish.map.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ beforeEach(async (t) => {
const server = fastify({ logger: false });
const service = new EikService({ customSink: memSink });
server.register(service.api());
const address = await server.listen();
const address = await server.listen({
host: '127.0.0.1',
port: 0,
});

const token = await cli.login({
server: address,
Expand Down
5 changes: 4 additions & 1 deletion test/publish.package.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ beforeEach(async (t) => {
const server = fastify({ logger: false });
const service = new EikService({ customSink: memSink });
server.register(service.api());
const address = await server.listen();
const address = await server.listen({
host: '127.0.0.1',
port: 0,
});

const token = await cli.login({
server: address,
Expand Down
40 changes: 32 additions & 8 deletions test/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ test('fetch latest version for a given published bundle', async (t) => {
[2, { version: '2.1.8' }],
],
}));
const address = await server.listen();
const address = await server.listen({
host: '127.0.0.1',
port: 0,
});

const version = await f.latestVersion(address, 'pkg', 'foo');

Expand All @@ -93,7 +96,10 @@ test('fetch latest version, filtered by major, for a given published bundle', as
[2, { version: '2.1.8' }],
],
}));
const address = await server.listen();
const address = await server.listen({
host: '127.0.0.1',
port: 0,
});

const version = await f.latestVersion(address, 'pkg', 'foo', 1);

Expand All @@ -104,7 +110,10 @@ test('fetch latest version, filtered by major, for a given published bundle', as

test('fetch latest version for a given published bundle, non existant bundle on server', async (t) => {
const server = fastify();
const address = await server.listen();
const address = await server.listen({
host: '127.0.0.1',
port: 0,
});

try {
await f.latestVersion(address, 'pkg', 'foo');
Expand All @@ -122,7 +131,10 @@ test('fetch latest version for a given published bundle, non existant bundle on
test('fetch latest version, filtered by major, for a given published bundle', async (t) => {
const server = fastify();
server.get('/pkg/foo', async () => '');
const address = await server.listen();
const address = await server.listen({
host: '127.0.0.1',
port: 0,
});

try {
await f.latestVersion(address, 'pkg', 'foo');
Expand All @@ -140,7 +152,10 @@ test('fetch latest version, filtered by major, for a given published bundle', as
test('fetch latest version, invalid versions returned by server', async (t) => {
const server = fastify();
server.get('/pkg/foo', async () => ({ versions: 1 }));
const address = await server.listen();
const address = await server.listen({
host: '127.0.0.1',
port: 0,
});

t.rejects(
f.latestVersion(address, 'pkg', 'foo'),
Expand All @@ -158,7 +173,10 @@ test('fetch latest version, invalid versions keys returned by server', async (t)
['also not a number', 2],
],
}));
const address = await server.listen();
const address = await server.listen({
host: '127.0.0.1',
port: 0,
});

t.rejects(
f.latestVersion(address, 'pkg', 'foo'),
Expand All @@ -174,7 +192,10 @@ test('fetch latest version, no bundles yet published', async (t) => {
latest: {},
versions: [],
}));
const address = await server.listen();
const address = await server.listen({
host: '127.0.0.1',
port: 0,
});

const version = await f.latestVersion(address, 'pkg', 'foo');

Expand All @@ -199,7 +220,10 @@ test('fetch remote hash for a given version', async (t) => {
},
],
}));
const address = await server.listen();
const address = await server.listen({
host: '127.0.0.1',
port: 0,
});
const result = await f.integrity(address, 'pkg', 'foo', '1.0.0');

t.equal(
Expand Down
5 changes: 4 additions & 1 deletion test/version.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ beforeEach(async (t) => {
const server = fastify({ logger: false });
const service = new EikService({ customSink: memSink });
server.register(service.api());
const address = await server.listen();
const address = await server.listen({
host: '127.0.0.1',
port: 0,
});

const token = await cli.login({
server: address,
Expand Down

0 comments on commit ee93a4b

Please sign in to comment.