@@ -765,12 +765,41 @@ describe('deployPackage', () => {
765
765
json : ( ) => result
766
766
} )
767
767
768
- const supportedClientRuntimes = [ 'nodejs:10' , 'nodejs:12' , 'nodejs:14' , 'nodejs:16' , 'nodejs:18' ]
769
- const supportedServerRuntimes = await utils . getSupportedServerRuntimes ( initOptions . apihost )
768
+ await expect ( ( ) =>
769
+ utils . deployPackage ( JSON . parse ( fs . readFileSync ( '/basic_manifest_unsupported_kind.json' ) ) , ow , mockLogger , imsOrgId )
770
+ ) . rejects . toThrow ( / U n s u p p o r t e d n o d e v e r s i o n ' n o d e j s : 8 / )
771
+ } )
772
+
773
+ test ( 'basic manifest - local `kind` list missing' , async ( ) => {
774
+ const imsOrgId = 'MyIMSOrgId'
775
+ const mockLogger = jest . fn ( )
776
+ const actionOptions = {
777
+ apiKey : 'my-key' ,
778
+ namespace : 'my-namespace'
779
+ }
780
+ const initOptions = {
781
+ apihost : 'https://adobeio.adobeioruntime.net'
782
+ }
783
+ ow . mockResolvedProperty ( 'actions.client.options' , actionOptions )
784
+ ow . mockResolvedProperty ( owInitOptions , initOptions )
785
+
786
+ const result = {
787
+ runtimes : {
788
+ nodejs : [
789
+ { kind : 'nodejs:8' } , // server says it supports nodejs:8!
790
+ { kind : 'nodejs:16' }
791
+ ]
792
+ }
793
+ }
794
+ mockFetch . mockResolvedValue ( {
795
+ ok : true ,
796
+ status : 200 ,
797
+ json : ( ) => result
798
+ } )
770
799
771
800
await expect ( ( ) =>
772
801
utils . deployPackage ( JSON . parse ( fs . readFileSync ( '/basic_manifest_unsupported_kind.json' ) ) , ow , mockLogger , imsOrgId )
773
- ) . rejects . toThrow ( `Unsupported node version 'nodejs:8' in action hello/helloAction. Supported versions are ${ supportedClientRuntimes } . Supported runtimes on ${ initOptions . apihost } : ${ supportedServerRuntimes } ` )
802
+ ) . not . toThrow ( )
774
803
} )
775
804
776
805
test ( 'basic manifest (fetch error)' , async ( ) => {
@@ -2243,10 +2272,20 @@ describe('validateActionRuntime', () => {
2243
2272
expect ( ( ) => utils . validateActionRuntime ( { exec : { kind : 'nodejs:16' } } ) ) . not . toThrow ( )
2244
2273
expect ( ( ) => utils . validateActionRuntime ( { exec : { kind : 'nodejs:18' } } ) ) . not . toThrow ( )
2245
2274
} )
2246
-
2247
- test ( 'invalid nodejs version' , async ( ) => {
2248
- const func = ( ) => utils . validateActionRuntime ( { exec : { kind : 'nodejs:17' } } )
2249
- expect ( func ) . toThrowError ( 'Unsupported node version' )
2275
+ test ( 'no exec' , ( ) => {
2276
+ expect ( utils . validateActionRuntime ( { } ) ) . toBeUndefined ( )
2277
+ } )
2278
+ test ( 'no runtime kind' , ( ) => {
2279
+ expect ( utils . validateActionRuntime ( { exec : { } } ) ) . toBeUndefined ( )
2280
+ } )
2281
+ test ( 'valid runtime kind' , ( ) => {
2282
+ expect ( utils . validateActionRuntime ( { exec : { kind : 'nodejs:14' } } ) ) . toBeUndefined ( )
2283
+ } )
2284
+ test ( 'valid runtime kind - toLower' , ( ) => {
2285
+ expect ( ( ) => utils . validateActionRuntime ( { exec : { kind : 'NODEJS:14' } } ) ) . toThrowError ( 'Unsupported node version' )
2286
+ } )
2287
+ test ( 'invalid nodejs version' , ( ) => {
2288
+ expect ( ( ) => utils . validateActionRuntime ( { exec : { kind : 'nodejs:17' } } ) ) . toThrowError ( 'Unsupported node version' )
2250
2289
} )
2251
2290
2252
2291
test ( 'dumpActionsBuiltInfo might catch some errors under unlikely conditions' , async ( ) => {
0 commit comments