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

feat: add suport for node16 runtime #640

Merged
merged 10 commits into from
Feb 24, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/armTemplates/resources/functionApp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,23 @@ describe("Function App Resource", () => {
expect(functionAppNodeVersion.value).toEqual("~12");
});

it("gets correct parameters - node 16", () => {
const config = getConfig(FunctionAppOS.LINUX, Runtime.NODE16);

const resource = new FunctionAppResource();

const params = resource.getParameters(config);
const {
linuxFxVersion,
functionAppNodeVersion,
} = params;

assertLinuxParams(params);

expect(linuxFxVersion.value).toEqual("NODE|16");
expect(functionAppNodeVersion.value).toEqual("~16");
});

it("gets correct parameters - python 3.6", () => {
const config = getConfig(FunctionAppOS.LINUX, Runtime.PYTHON36);

Expand Down
17 changes: 17 additions & 0 deletions src/config/runtime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ describe("Runtime", () => {
expect(isNodeRuntime(Runtime.NODE10)).toBe(true);
expect(isNodeRuntime(Runtime.NODE12)).toBe(true);
expect(isNodeRuntime(Runtime.NODE14)).toBe(true);
expect(isNodeRuntime(Runtime.NODE16)).toBe(true);
expect(isNodeRuntime(Runtime.PYTHON36)).toBe(false);
expect(isNodeRuntime(Runtime.PYTHON37)).toBe(false);
expect(isNodeRuntime(Runtime.PYTHON38)).toBe(false);
Expand All @@ -15,6 +16,7 @@ describe("Runtime", () => {
expect(isPythonRuntime(Runtime.NODE10)).toBe(false);
expect(isPythonRuntime(Runtime.NODE12)).toBe(false);
expect(isPythonRuntime(Runtime.NODE14)).toBe(false);
expect(isPythonRuntime(Runtime.NODE16)).toBe(false);
expect(isPythonRuntime(Runtime.PYTHON36)).toBe(true);
expect(isPythonRuntime(Runtime.PYTHON37)).toBe(true);
expect(isPythonRuntime(Runtime.PYTHON38)).toBe(true);
Expand All @@ -24,24 +26,39 @@ describe("Runtime", () => {
expect(getRuntimeVersion(Runtime.NODE10)).toBe("10");
expect(getRuntimeVersion(Runtime.NODE12)).toBe("12");
expect(getRuntimeVersion(Runtime.NODE14)).toBe("14");
expect(getRuntimeVersion(Runtime.NODE16)).toBe("16");
expect(getRuntimeVersion(Runtime.PYTHON36)).toBe("3.6");
expect(getRuntimeVersion(Runtime.PYTHON37)).toBe("3.7");
expect(getRuntimeVersion(Runtime.PYTHON38)).toBe("3.8");
});

it("throw exception on get runtime version", () => {
Runtime["invalid"] = "invalid"
expect(() => { getRuntimeVersion(Runtime["invalid"]) }).toThrowError("Runtime invalid not included in supportedRuntimes")
delete Runtime["invalid"]
})

it("gets runtime language", () => {
expect(getRuntimeLanguage(Runtime.NODE10)).toBe("nodejs");
expect(getRuntimeLanguage(Runtime.NODE12)).toBe("nodejs");
expect(getRuntimeLanguage(Runtime.NODE14)).toBe("nodejs");
expect(getRuntimeLanguage(Runtime.NODE16)).toBe("nodejs");
expect(getRuntimeLanguage(Runtime.PYTHON36)).toBe("python");
expect(getRuntimeLanguage(Runtime.PYTHON37)).toBe("python");
expect(getRuntimeLanguage(Runtime.PYTHON38)).toBe("python");
});

it("throw exception on get runtime language", () => {
Runtime["invalid"] = "invalid"
expect(() => { getRuntimeLanguage(Runtime["invalid"]) }).toThrowError("Runtime invalid not included in supportedRuntimes")
delete Runtime["invalid"]
})

it("gets function worker runtime", () => {
expect(getFunctionWorkerRuntime(Runtime.NODE10)).toBe("node");
expect(getFunctionWorkerRuntime(Runtime.NODE12)).toBe("node");
expect(getFunctionWorkerRuntime(Runtime.NODE14)).toBe("node");
expect(getFunctionWorkerRuntime(Runtime.NODE16)).toBe("node");
expect(getFunctionWorkerRuntime(Runtime.PYTHON36)).toBe("python");
expect(getFunctionWorkerRuntime(Runtime.PYTHON37)).toBe("python");
expect(getFunctionWorkerRuntime(Runtime.PYTHON38)).toBe("python");
Expand Down
3 changes: 3 additions & 0 deletions src/config/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export enum Runtime {
NODE10 = "nodejs10",
NODE12 = "nodejs12",
NODE14 = "nodejs14",
NODE16 = "nodejs16",
PYTHON36 = "python3.6",
PYTHON37 = "python3.7",
PYTHON38 = "python3.8",
Expand All @@ -14,6 +15,7 @@ export const supportedRuntimes = [
Runtime.NODE10,
Runtime.NODE12,
Runtime.NODE14,
Runtime.NODE16,
Runtime.PYTHON36,
Runtime.PYTHON37,
Runtime.PYTHON38,
Expand Down Expand Up @@ -92,6 +94,7 @@ export const dockerImages = {
nodejs10: "NODE|10",
nodejs12: "NODE|12",
nodejs14: "NODE|14",
nodejs16: "NODE|16",
"python3.6": "PYTHON|3.6",
"python3.7": "PYTHON|3.7",
"python3.8": "PYTHON|3.8",
Expand Down
8 changes: 4 additions & 4 deletions src/services/configService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,23 +225,23 @@ describe("Config Service", () => {
sls.service.provider.runtime = "python2.7" as any;
expect(() => new ConfigService(sls, {} as any))
.toThrowError("Runtime python2.7 is not supported. " +
"Runtimes supported: nodejs10,nodejs12,nodejs14,python3.6,python3.7,python3.8");
"Runtimes supported: nodejs10,nodejs12,nodejs14,nodejs16,python3.6,python3.7,python3.8");
});

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

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

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

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