Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jonirap committed Sep 1, 2023
1 parent 771bc76 commit 4a1ea7f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Server } from 'http';
import { CloudEventFunction, HTTPFunction, InvokerOptions } from './lib/types';
import { CloudEventFunction, HTTPFunction, InvokerOptions, Function } from './lib/types';
import { LogLevel } from 'fastify';

// Invokable describes the function signature for a function that can be invoked by the server.
Expand All @@ -21,7 +21,7 @@ export declare const defaults: {
LOG_LEVEL: LogLevel,
PORT: number,
INCLUDE_RAW: boolean,
}
};

// re-export
export * from './lib/types';
8 changes: 4 additions & 4 deletions lib/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import { Http2ServerRequest, Http2ServerResponse } from 'http2';
*/
export interface Function {
// The initialization function, called before the server is started
// This function is optional and should be synchronous.
init?: () => any | Promise<any>;
// This function is optional.
init?: () => (any | Promise<any>);

// The shutdown function, called after the server is stopped
// This function is optional and should be synchronous.
shutdown?: () => any | Promise<any>;
// This function is optional.
shutdown?: () => (any | Promise<any>);

// The liveness function, called to check if the server is alive
// This function is optional and should return 200/OK if the server is alive.
Expand Down
14 changes: 6 additions & 8 deletions test/test-lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ test('Calls async init before the server has started', async t => {
let initCalled = false;
const server = await start(
{
init: () =>
new Promise(() => {
initCalled = true;
}),
init: async() => {
initCalled = true;
},
handle: () => {},
},
defaults
Expand Down Expand Up @@ -88,10 +87,9 @@ test('Calls async shutdown after the server has stopped', async t => {
const server = await start(
{
handle: () => {},
shutdown: _ =>
new Promise(_ => {
shutdownCalled = true;
}),
shutdown: async() => {
shutdownCalled = true;
},
},
defaults
);
Expand Down

0 comments on commit 4a1ea7f

Please sign in to comment.