Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore proxy functions for loading #299

Merged
merged 2 commits into from May 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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