Skip to content

Commit

Permalink
test: configure fastify to force-close connections on close
Browse files Browse the repository at this point in the history
  • Loading branch information
wkillerud committed Nov 18, 2024
1 parent 185fba5 commit 484480c
Show file tree
Hide file tree
Showing 17 changed files with 96 additions and 24 deletions.
5 changes: 4 additions & 1 deletion test/alias.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

beforeEach(async (t) => {
const server = fastify({ ignoreTrailingSlash: true });
const server = fastify({
ignoreTrailingSlash: true,
forceCloseConnections: true,
});
const memSink = new Sink();
const service = new EikService({ sink: memSink });
await server.register(service.api());
Expand Down
5 changes: 4 additions & 1 deletion test/integration/alias-legacy.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ function exec(cmd) {
}

beforeEach(async (t) => {
const server = fastify({ ignoreTrailingSlash: true });
const server = fastify({
ignoreTrailingSlash: true,
forceCloseConnections: true,
});
const memSink = new Sink();
const service = new EikService({ sink: memSink });
await server.register(service.api());
Expand Down
5 changes: 4 additions & 1 deletion test/integration/alias.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ function exec(cmd) {
}

beforeEach(async (t) => {
const server = fastify({ ignoreTrailingSlash: true });
const server = fastify({
ignoreTrailingSlash: true,
forceCloseConnections: true,
});
const memSink = new Sink();
const service = new EikService({ sink: memSink });
await server.register(service.api());
Expand Down
5 changes: 4 additions & 1 deletion test/integration/integrity.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ function exec(cmd) {

beforeEach(async (t) => {
const memSink = new Sink();
const server = fastify({ ignoreTrailingSlash: true });
const server = fastify({
ignoreTrailingSlash: true,
forceCloseConnections: true,
});
const service = new EikService({ sink: memSink });
await server.register(service.api());
const address = await server.listen({
Expand Down
5 changes: 4 additions & 1 deletion test/integration/login.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ function exec(cmd) {

beforeEach(async (t) => {
const memSink = new Sink();
const server = fastify({ ignoreTrailingSlash: true });
const server = fastify({
ignoreTrailingSlash: true,
forceCloseConnections: true,
});
const service = new EikService({ sink: memSink });
await server.register(service.api());
const address = await server.listen({
Expand Down
5 changes: 4 additions & 1 deletion test/integration/map.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ function exec(cmd) {

beforeEach(async (t) => {
const memSink = new Sink();
const server = fastify({ ignoreTrailingSlash: true });
const server = fastify({
ignoreTrailingSlash: true,
forceCloseConnections: true,
});
const service = new EikService({ sink: memSink });
await server.register(service.api());
const address = await server.listen({
Expand Down
5 changes: 4 additions & 1 deletion test/integration/meta.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ function exec(cmd) {

beforeEach(async (t) => {
const memSink = new Sink();
const server = fastify({ ignoreTrailingSlash: true });
const server = fastify({
ignoreTrailingSlash: true,
forceCloseConnections: true,
});
const service = new EikService({ sink: memSink });
await server.register(service.api());
const address = await server.listen({
Expand Down
5 changes: 4 additions & 1 deletion test/integration/package.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ function exec(cmd) {

beforeEach(async (t) => {
const memSink = new Sink();
const server = fastify({ ignoreTrailingSlash: true });
const server = fastify({
ignoreTrailingSlash: true,
forceCloseConnections: true,
});
const service = new EikService({ sink: memSink });
await server.register(service.api());
const address = await server.listen({
Expand Down
5 changes: 4 additions & 1 deletion test/integration/version.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ function exec(cmd, opts = {}) {

beforeEach(async (t) => {
const memSink = new Sink();
const server = fastify({ ignoreTrailingSlash: true });
const server = fastify({
ignoreTrailingSlash: true,
forceCloseConnections: true,
});
const service = new EikService({ sink: memSink });
await server.register(service.api());
const address = await server.listen({
Expand Down
5 changes: 4 additions & 1 deletion test/integrity.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

beforeEach(async (t) => {
const server = fastify({ ignoreTrailingSlash: true });
const server = fastify({
ignoreTrailingSlash: true,
forceCloseConnections: true,
});
const memSink = new Sink();
const service = new EikService({ sink: memSink });
await server.register(service.api());
Expand Down
5 changes: 4 additions & 1 deletion test/login.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ const __dirname = dirname(__filename);

beforeEach(async (t) => {
const memSink = new Sink();
const server = fastify({ ignoreTrailingSlash: true });
const server = fastify({
ignoreTrailingSlash: true,
forceCloseConnections: true,
});
const service = new EikService({ sink: memSink });
await server.register(service.api());
const address = await server.listen({
Expand Down
5 changes: 4 additions & 1 deletion test/meta.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

beforeEach(async (t) => {
const server = fastify({ ignoreTrailingSlash: true });
const server = fastify({
ignoreTrailingSlash: true,
forceCloseConnections: true,
});
const memSink = new Sink();
const service = new EikService({ sink: memSink });
await server.register(service.api());
Expand Down
5 changes: 4 additions & 1 deletion test/publish-files-definitions.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ const config = (files, server, token, cwd) => ({

beforeEach(async (t) => {
const memSink = new Sink();
const server = fastify({ ignoreTrailingSlash: true });
const server = fastify({
ignoreTrailingSlash: true,
forceCloseConnections: true,
});
const service = new EikService({ sink: memSink });
await server.register(service.api());
const address = await server.listen({
Expand Down
5 changes: 4 additions & 1 deletion test/publish.map.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ const __dirname = dirname(__filename);

beforeEach(async (t) => {
const memSink = new Sink();
const server = fastify({ ignoreTrailingSlash: true });
const server = fastify({
ignoreTrailingSlash: true,
forceCloseConnections: true,
});
const service = new EikService({ sink: memSink });
await server.register(service.api());
const address = await server.listen({
Expand Down
5 changes: 4 additions & 1 deletion test/publish.package.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ const __dirname = dirname(__filename);

beforeEach(async (t) => {
const memSink = new Sink();
const server = fastify({ ignoreTrailingSlash: true });
const server = fastify({
ignoreTrailingSlash: true,
forceCloseConnections: true,
});
const service = new EikService({ sink: memSink });
await server.register(service.api());
const address = await server.listen({
Expand Down
40 changes: 32 additions & 8 deletions test/utils.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ test("compare hashes - false", async (t) => {
});

test("fetch latest version for a given published bundle", async (t) => {
const server = fastify({ ignoreTrailingSlash: true });
const server = fastify({
ignoreTrailingSlash: true,
forceCloseConnections: true,
});
server.get("/pkg/foo", async () => ({
versions: [
[1, { version: "1.3.2" }],
Expand All @@ -93,7 +96,10 @@ test("fetch latest version for a given published bundle", async (t) => {
});

test("fetch latest version, filtered by major, for a given published bundle", async (t) => {
const server = fastify({ ignoreTrailingSlash: true });
const server = fastify({
ignoreTrailingSlash: true,
forceCloseConnections: true,
});
server.get("/pkg/foo", async () => ({
versions: [
[1, { version: "1.3.2" }],
Expand All @@ -113,7 +119,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({ ignoreTrailingSlash: true });
const server = fastify({
ignoreTrailingSlash: true,
forceCloseConnections: true,
});
const address = await server.listen({
host: "127.0.0.1",
port: 0,
Expand All @@ -133,7 +142,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({ ignoreTrailingSlash: true });
const server = fastify({
ignoreTrailingSlash: true,
forceCloseConnections: true,
});
server.get("/pkg/foo", async () => "");
const address = await server.listen({
host: "127.0.0.1",
Expand All @@ -154,7 +166,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({ ignoreTrailingSlash: true });
const server = fastify({
ignoreTrailingSlash: true,
forceCloseConnections: true,
});
server.get("/pkg/foo", async () => ({ versions: 1 }));
const address = await server.listen({
host: "127.0.0.1",
Expand All @@ -170,7 +185,10 @@ test("fetch latest version, invalid versions returned by server", async (t) => {
});

test("fetch latest version, invalid versions keys returned by server", async (t) => {
const server = fastify({ ignoreTrailingSlash: true });
const server = fastify({
ignoreTrailingSlash: true,
forceCloseConnections: true,
});
server.get("/pkg/foo", async () => ({
versions: [
["not a number", 1],
Expand All @@ -191,7 +209,10 @@ test("fetch latest version, invalid versions keys returned by server", async (t)
});

test("fetch latest version, no bundles yet published", async (t) => {
const server = fastify({ ignoreTrailingSlash: true });
const server = fastify({
ignoreTrailingSlash: true,
forceCloseConnections: true,
});
server.get("/pkg/foo", async () => ({
latest: {},
versions: [],
Expand All @@ -209,7 +230,10 @@ test("fetch latest version, no bundles yet published", async (t) => {
});

test("fetch remote hash for a given version", async (t) => {
const server = fastify({ ignoreTrailingSlash: true });
const server = fastify({
ignoreTrailingSlash: true,
forceCloseConnections: true,
});
server.get("/pkg/foo/1.0.0", async () => ({
integrity:
"sha512-36Ug1lJ/p/H0n5+or1HDLrqLaI3nvB7j2f7PC9RIzWd3T5GE4CfOuClEZRiNsf/F4BjT5FnS9mz0EzeDHpu3uw==",
Expand Down
5 changes: 4 additions & 1 deletion test/version.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ const __dirname = dirname(__filename);

beforeEach(async (t) => {
const memSink = new Sink();
const server = fastify({ ignoreTrailingSlash: true });
const server = fastify({
ignoreTrailingSlash: true,
forceCloseConnections: true,
});
const service = new EikService({ sink: memSink });
await server.register(service.api());
const address = await server.listen({
Expand Down

0 comments on commit 484480c

Please sign in to comment.