Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hossam-nasr committed Jun 24, 2022
1 parent 43da21a commit 2aa5cfe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
15 changes: 10 additions & 5 deletions test/eventHandlers/InvocationHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import * as sinon from 'sinon';
import { AzureFunctionsRpcMessages as rpc } from '../../azure-functions-language-worker-protobuf/src/rpc';
import { FunctionInfo } from '../../src/FunctionInfo';
import { FunctionLoader } from '../../src/FunctionLoader';
import { WorkerChannel } from '../../src/WorkerChannel';
import { Msg as AppStartMsg } from '../startApp.test';
import { beforeEventHandlerSuite } from './beforeEventHandlerSuite';
import { TestEventStream } from './TestEventStream';
import { Msg as WorkerInitMsg } from './WorkerInitHandler.test';
Expand Down Expand Up @@ -323,16 +325,19 @@ namespace InputData {
describe('InvocationHandler', () => {
let stream: TestEventStream;
let loader: sinon.SinonStubbedInstance<FunctionLoader>;
let channel: WorkerChannel;
let coreApi: typeof coreTypes;
let testDisposables: coreTypes.Disposable[] = [];

before(async () => {
({ stream, loader } = beforeEventHandlerSuite());
({ stream, loader, channel } = beforeEventHandlerSuite());
coreApi = await import('@azure/functions-core');
});

beforeEach(async () => {
hookData = '';
channel.appHookData = {};
channel.appLevelOnlyHookData = {};
});

afterEach(async () => {
Expand Down Expand Up @@ -779,8 +784,8 @@ describe('InvocationHandler', () => {
await stream.assertCalledWith(
WorkerInitMsg.receivedInitLog,
WorkerInitMsg.warning('Worker failed to load package.json: file does not exist'),
Msg.executingHooksLog(1, 'appStart'),
Msg.executedHooksLog('appStart'),
AppStartMsg.executingHooksLog(1, 'appStart'),
AppStartMsg.executedHooksLog('appStart'),
WorkerInitMsg.response
);
expect(startFunc.callCount).to.be.equal(1);
Expand Down Expand Up @@ -832,8 +837,8 @@ describe('InvocationHandler', () => {
await stream.assertCalledWith(
WorkerInitMsg.receivedInitLog,
WorkerInitMsg.warning('Worker failed to load package.json: file does not exist'),
Msg.executingHooksLog(1, 'appStart'),
Msg.executedHooksLog('appStart'),
AppStartMsg.executingHooksLog(1, 'appStart'),
AppStartMsg.executedHooksLog('appStart'),
WorkerInitMsg.response
);
expect(startFunc.callCount).to.be.equal(1);
Expand Down
4 changes: 3 additions & 1 deletion test/startApp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Msg as WorkerInitMsg } from './eventHandlers/WorkerInitHandler.test';
import LogCategory = rpc.RpcLog.RpcLogCategory;
import LogLevel = rpc.RpcLog.Level;

namespace Msg {
export namespace Msg {
export function executingHooksLog(count: number, hookName: string): rpc.IStreamingMessage {
return {
rpcLog: {
Expand Down Expand Up @@ -62,6 +62,8 @@ describe('startApp', () => {
coreApi.Disposable.from(...testDisposables).dispose();
testDisposables = [];
process.chdir(originalCwd);
channel.appHookData = {};
channel.appLevelOnlyHookData = {};
});

it('runs app start hooks in non-specialization scenario', async () => {
Expand Down

0 comments on commit 2aa5cfe

Please sign in to comment.