Skip to content

Commit 2aa5cfe

Browse files
committed
fix tests
1 parent 43da21a commit 2aa5cfe

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

test/eventHandlers/InvocationHandler.test.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import * as sinon from 'sinon';
1111
import { AzureFunctionsRpcMessages as rpc } from '../../azure-functions-language-worker-protobuf/src/rpc';
1212
import { FunctionInfo } from '../../src/FunctionInfo';
1313
import { FunctionLoader } from '../../src/FunctionLoader';
14+
import { WorkerChannel } from '../../src/WorkerChannel';
15+
import { Msg as AppStartMsg } from '../startApp.test';
1416
import { beforeEventHandlerSuite } from './beforeEventHandlerSuite';
1517
import { TestEventStream } from './TestEventStream';
1618
import { Msg as WorkerInitMsg } from './WorkerInitHandler.test';
@@ -323,16 +325,19 @@ namespace InputData {
323325
describe('InvocationHandler', () => {
324326
let stream: TestEventStream;
325327
let loader: sinon.SinonStubbedInstance<FunctionLoader>;
328+
let channel: WorkerChannel;
326329
let coreApi: typeof coreTypes;
327330
let testDisposables: coreTypes.Disposable[] = [];
328331

329332
before(async () => {
330-
({ stream, loader } = beforeEventHandlerSuite());
333+
({ stream, loader, channel } = beforeEventHandlerSuite());
331334
coreApi = await import('@azure/functions-core');
332335
});
333336

334337
beforeEach(async () => {
335338
hookData = '';
339+
channel.appHookData = {};
340+
channel.appLevelOnlyHookData = {};
336341
});
337342

338343
afterEach(async () => {
@@ -779,8 +784,8 @@ describe('InvocationHandler', () => {
779784
await stream.assertCalledWith(
780785
WorkerInitMsg.receivedInitLog,
781786
WorkerInitMsg.warning('Worker failed to load package.json: file does not exist'),
782-
Msg.executingHooksLog(1, 'appStart'),
783-
Msg.executedHooksLog('appStart'),
787+
AppStartMsg.executingHooksLog(1, 'appStart'),
788+
AppStartMsg.executedHooksLog('appStart'),
784789
WorkerInitMsg.response
785790
);
786791
expect(startFunc.callCount).to.be.equal(1);
@@ -832,8 +837,8 @@ describe('InvocationHandler', () => {
832837
await stream.assertCalledWith(
833838
WorkerInitMsg.receivedInitLog,
834839
WorkerInitMsg.warning('Worker failed to load package.json: file does not exist'),
835-
Msg.executingHooksLog(1, 'appStart'),
836-
Msg.executedHooksLog('appStart'),
840+
AppStartMsg.executingHooksLog(1, 'appStart'),
841+
AppStartMsg.executedHooksLog('appStart'),
837842
WorkerInitMsg.response
838843
);
839844
expect(startFunc.callCount).to.be.equal(1);

test/startApp.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { Msg as WorkerInitMsg } from './eventHandlers/WorkerInitHandler.test';
1313
import LogCategory = rpc.RpcLog.RpcLogCategory;
1414
import LogLevel = rpc.RpcLog.Level;
1515

16-
namespace Msg {
16+
export namespace Msg {
1717
export function executingHooksLog(count: number, hookName: string): rpc.IStreamingMessage {
1818
return {
1919
rpcLog: {
@@ -62,6 +62,8 @@ describe('startApp', () => {
6262
coreApi.Disposable.from(...testDisposables).dispose();
6363
testDisposables = [];
6464
process.chdir(originalCwd);
65+
channel.appHookData = {};
66+
channel.appLevelOnlyHookData = {};
6567
});
6668

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

0 commit comments

Comments
 (0)