Skip to content

Commit

Permalink
Ignore proxy functions for loading (#299)
Browse files Browse the repository at this point in the history
* do not load proxy functions

* check against true
  • Loading branch information
mhoeger committed May 26, 2020
1 parent f836765 commit cd90fe5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/FunctionLoader.ts
Expand Up @@ -17,6 +17,9 @@ export class FunctionLoader implements IFunctionLoader {
}} = {};

load(functionId: string, metadata: rpc.IRpcFunctionMetadata): void {
if (metadata.isProxy === true) {
return;
}
let scriptFilePath = <string>(metadata && metadata.scriptFile);
let script = require(scriptFilePath);
let entryPoint = <string>(metadata && metadata.entryPoint);
Expand Down
11 changes: 11 additions & 0 deletions test/FunctionLoaderTests.ts
Expand Up @@ -36,6 +36,17 @@ describe('FunctionLoader', () => {
}).to.throw("Unable to determine function entry point. If multiple functions are exported, you must indicate the entry point, either by naming it 'run' or 'index', or by naming it explicitly via the 'entryPoint' metadata property.");
});

it ('does not load proxy function', () => {
mock('test', {});
loader.load('functionId', <rpc.IRpcFunctionMetadata> {
isProxy: true
});

expect(() => {
loader.getFunc('functionId');
}).to.throw("Function code for 'functionId' is not loaded and cannot be invoked.");
});

it ('throws unable to determine function entry point with entryPoint name', () => {
mock('test', { test: {} });
let entryPoint = 'wrongEntryPoint'
Expand Down

0 comments on commit cd90fe5

Please sign in to comment.