File tree 2 files changed +20
-12
lines changed 2 files changed +20
-12
lines changed Original file line number Diff line number Diff line change @@ -121,7 +121,7 @@ export async function getUserFunction(
121
121
return registeredFunction ;
122
122
}
123
123
124
- let userFunction = functionTarget
124
+ const userFunction = functionTarget
125
125
. split ( '.' )
126
126
. reduce ( ( code , functionTargetPart ) => {
127
127
if ( typeof code === 'undefined' ) {
@@ -131,18 +131,12 @@ export async function getUserFunction(
131
131
}
132
132
} , functionModule ) ;
133
133
134
- // TODO: do we want 'function' fallback?
135
134
if ( typeof userFunction === 'undefined' ) {
136
- // eslint-disable-next-line no-prototype-builtins
137
- if ( functionModule . hasOwnProperty ( 'function' ) ) {
138
- userFunction = functionModule [ 'function' ] ;
139
- } else {
140
- console . error (
141
- `Function '${ functionTarget } ' is not defined in the provided ` +
142
- 'module.\nDid you specify the correct target function to execute?'
143
- ) ;
144
- return null ;
145
- }
135
+ console . error (
136
+ `Function '${ functionTarget } ' is not defined in the provided ` +
137
+ 'module.\nDid you specify the correct target function to execute?'
138
+ ) ;
139
+ return null ;
146
140
}
147
141
148
142
if ( typeof userFunction !== 'function' ) {
Original file line number Diff line number Diff line change @@ -93,6 +93,20 @@ describe('loading function', () => {
93
93
}
94
94
}
95
95
96
+ it ( 'fails to load a function that does not exist' , async ( ) => {
97
+ FunctionRegistry . http ( 'function' , ( ) => {
98
+ return 'PASS' ;
99
+ } ) ;
100
+
101
+ const loadedFunction = await loader . getUserFunction (
102
+ process . cwd ( ) + '/test/data/with_main' ,
103
+ 'functionDoesNotExist' ,
104
+ 'http'
105
+ ) ;
106
+
107
+ assert . strictEqual ( loadedFunction , null ) ;
108
+ } ) ;
109
+
96
110
it ( 'loads a declaratively registered function' , async ( ) => {
97
111
FunctionRegistry . http ( 'registeredFunction' , ( ) => {
98
112
return 'PASS' ;
You can’t perform that action at this time.
0 commit comments