Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.

Commit 33f82d2

Browse files
authored
feat: Support node16 runtime (#640)
1 parent f1c480f commit 33f82d2

File tree

4 files changed

+41
-4
lines changed

4 files changed

+41
-4
lines changed

src/armTemplates/resources/functionApp.test.ts

+17
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,23 @@ describe("Function App Resource", () => {
214214
expect(functionAppNodeVersion.value).toEqual("~12");
215215
});
216216

217+
it("gets correct parameters - node 16", () => {
218+
const config = getConfig(FunctionAppOS.LINUX, Runtime.NODE16);
219+
220+
const resource = new FunctionAppResource();
221+
222+
const params = resource.getParameters(config);
223+
const {
224+
linuxFxVersion,
225+
functionAppNodeVersion,
226+
} = params;
227+
228+
assertLinuxParams(params);
229+
230+
expect(linuxFxVersion.value).toEqual("NODE|16");
231+
expect(functionAppNodeVersion.value).toEqual("~16");
232+
});
233+
217234
it("gets correct parameters - python 3.6", () => {
218235
const config = getConfig(FunctionAppOS.LINUX, Runtime.PYTHON36);
219236

src/config/runtime.test.ts

+17
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ describe("Runtime", () => {
66
expect(isNodeRuntime(Runtime.NODE10)).toBe(true);
77
expect(isNodeRuntime(Runtime.NODE12)).toBe(true);
88
expect(isNodeRuntime(Runtime.NODE14)).toBe(true);
9+
expect(isNodeRuntime(Runtime.NODE16)).toBe(true);
910
expect(isNodeRuntime(Runtime.PYTHON36)).toBe(false);
1011
expect(isNodeRuntime(Runtime.PYTHON37)).toBe(false);
1112
expect(isNodeRuntime(Runtime.PYTHON38)).toBe(false);
@@ -15,6 +16,7 @@ describe("Runtime", () => {
1516
expect(isPythonRuntime(Runtime.NODE10)).toBe(false);
1617
expect(isPythonRuntime(Runtime.NODE12)).toBe(false);
1718
expect(isPythonRuntime(Runtime.NODE14)).toBe(false);
19+
expect(isPythonRuntime(Runtime.NODE16)).toBe(false);
1820
expect(isPythonRuntime(Runtime.PYTHON36)).toBe(true);
1921
expect(isPythonRuntime(Runtime.PYTHON37)).toBe(true);
2022
expect(isPythonRuntime(Runtime.PYTHON38)).toBe(true);
@@ -24,24 +26,39 @@ describe("Runtime", () => {
2426
expect(getRuntimeVersion(Runtime.NODE10)).toBe("10");
2527
expect(getRuntimeVersion(Runtime.NODE12)).toBe("12");
2628
expect(getRuntimeVersion(Runtime.NODE14)).toBe("14");
29+
expect(getRuntimeVersion(Runtime.NODE16)).toBe("16");
2730
expect(getRuntimeVersion(Runtime.PYTHON36)).toBe("3.6");
2831
expect(getRuntimeVersion(Runtime.PYTHON37)).toBe("3.7");
2932
expect(getRuntimeVersion(Runtime.PYTHON38)).toBe("3.8");
3033
});
3134

35+
it("throw exception on get runtime version", () => {
36+
Runtime["invalid"] = "invalid"
37+
expect(() => { getRuntimeVersion(Runtime["invalid"]) }).toThrowError("Runtime invalid not included in supportedRuntimes")
38+
delete Runtime["invalid"]
39+
})
40+
3241
it("gets runtime language", () => {
3342
expect(getRuntimeLanguage(Runtime.NODE10)).toBe("nodejs");
3443
expect(getRuntimeLanguage(Runtime.NODE12)).toBe("nodejs");
3544
expect(getRuntimeLanguage(Runtime.NODE14)).toBe("nodejs");
45+
expect(getRuntimeLanguage(Runtime.NODE16)).toBe("nodejs");
3646
expect(getRuntimeLanguage(Runtime.PYTHON36)).toBe("python");
3747
expect(getRuntimeLanguage(Runtime.PYTHON37)).toBe("python");
3848
expect(getRuntimeLanguage(Runtime.PYTHON38)).toBe("python");
3949
});
4050

51+
it("throw exception on get runtime language", () => {
52+
Runtime["invalid"] = "invalid"
53+
expect(() => { getRuntimeLanguage(Runtime["invalid"]) }).toThrowError("Runtime invalid not included in supportedRuntimes")
54+
delete Runtime["invalid"]
55+
})
56+
4157
it("gets function worker runtime", () => {
4258
expect(getFunctionWorkerRuntime(Runtime.NODE10)).toBe("node");
4359
expect(getFunctionWorkerRuntime(Runtime.NODE12)).toBe("node");
4460
expect(getFunctionWorkerRuntime(Runtime.NODE14)).toBe("node");
61+
expect(getFunctionWorkerRuntime(Runtime.NODE16)).toBe("node");
4562
expect(getFunctionWorkerRuntime(Runtime.PYTHON36)).toBe("python");
4663
expect(getFunctionWorkerRuntime(Runtime.PYTHON37)).toBe("python");
4764
expect(getFunctionWorkerRuntime(Runtime.PYTHON38)).toBe("python");

src/config/runtime.ts

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export enum Runtime {
33
NODE10 = "nodejs10",
44
NODE12 = "nodejs12",
55
NODE14 = "nodejs14",
6+
NODE16 = "nodejs16",
67
PYTHON36 = "python3.6",
78
PYTHON37 = "python3.7",
89
PYTHON38 = "python3.8",
@@ -14,6 +15,7 @@ export const supportedRuntimes = [
1415
Runtime.NODE10,
1516
Runtime.NODE12,
1617
Runtime.NODE14,
18+
Runtime.NODE16,
1719
Runtime.PYTHON36,
1820
Runtime.PYTHON37,
1921
Runtime.PYTHON38,
@@ -92,6 +94,7 @@ export const dockerImages = {
9294
nodejs10: "NODE|10",
9395
nodejs12: "NODE|12",
9496
nodejs14: "NODE|14",
97+
nodejs16: "NODE|16",
9598
"python3.6": "PYTHON|3.6",
9699
"python3.7": "PYTHON|3.7",
97100
"python3.8": "PYTHON|3.8",

src/services/configService.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -225,23 +225,23 @@ describe("Config Service", () => {
225225
sls.service.provider.runtime = "python2.7" as any;
226226
expect(() => new ConfigService(sls, {} as any))
227227
.toThrowError("Runtime python2.7 is not supported. " +
228-
"Runtimes supported: nodejs10,nodejs12,nodejs14,python3.6,python3.7,python3.8");
228+
"Runtimes supported: nodejs10,nodejs12,nodejs14,nodejs16,python3.6,python3.7,python3.8");
229229
});
230230

231231
it("throws error when incomplete nodejs version in defined", () => {
232232
const sls = MockFactory.createTestServerless();
233233
sls.service.provider.runtime = "nodejs" as any;
234234
expect(() => new ConfigService(sls, {} as any))
235235
.toThrowError("Runtime nodejs is not supported. " +
236-
"Runtimes supported: nodejs10,nodejs12,nodejs14,python3.6,python3.7,python3.8");
236+
"Runtimes supported: nodejs10,nodejs12,nodejs14,nodejs16,python3.6,python3.7,python3.8");
237237
});
238238

239239
it("throws error when unsupported nodejs version in defined", () => {
240240
const sls = MockFactory.createTestServerless();
241241
sls.service.provider.runtime = "nodejs5.x" as any;
242242
expect(() => new ConfigService(sls, {} as any))
243243
.toThrowError("Runtime nodejs5.x is not supported. " +
244-
"Runtimes supported: nodejs10,nodejs12,nodejs14,python3.6,python3.7,python3.8");
244+
"Runtimes supported: nodejs10,nodejs12,nodejs14,nodejs16,python3.6,python3.7,python3.8");
245245
});
246246

247247
it("Does not throw an error when valid nodejs version is defined", () => {
@@ -258,7 +258,7 @@ describe("Config Service", () => {
258258
sls.service.provider.runtime = undefined;
259259
expect(() => new ConfigService(sls, {} as any))
260260
.toThrowError("Runtime undefined. " +
261-
"Runtimes supported: nodejs10,nodejs12,nodejs14,python3.6,python3.7,python3.8");
261+
"Runtimes supported: nodejs10,nodejs12,nodejs14,nodejs16,python3.6,python3.7,python3.8");
262262
});
263263

264264
it("does not throw an error with python3.6", () => {

0 commit comments

Comments
 (0)