From ee4b5d33e0805f0305feaed9afefdb5be8f1a988 Mon Sep 17 00:00:00 2001 From: Ganeshrockz Date: Wed, 14 Apr 2021 15:31:19 +0530 Subject: [PATCH] Comments --- __tests__/run.test.ts | 25 +++++++++++++++++++++++-- src/input-parameters.ts | 2 +- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/__tests__/run.test.ts b/__tests__/run.test.ts index bd5b59e1..1dd795f0 100644 --- a/__tests__/run.test.ts +++ b/__tests__/run.test.ts @@ -210,11 +210,32 @@ test("run() - deploy - Manifiest not provided", async () => { expect(coreMock.setFailed).toBeCalledWith('No manifests supplied to deploy'); }); +test("run() - deploy - Only one manifest with no delimiters", async () => { + const kubectlVersion = 'v1.18.0' + coreMock.getInput = jest.fn().mockImplementation((name) => { + if (name == 'manifests') { + return "bg-smi.yml"; + } + if (name == 'action') { + return 'deploy'; + } + return kubectlVersion; + }); + coreMock.setFailed = jest.fn(); + toolCacheMock.find = jest.fn().mockReturnValue(undefined); + toolCacheMock.downloadTool = jest.fn().mockReturnValue('downloadpath'); + toolCacheMock.cacheFile = jest.fn().mockReturnValue('cachepath'); + fileUtility.chmodSync = jest.fn(); + + //Invoke and assert + await expect(action.run()).resolves.not.toThrow(); +}); + test("run() - deploy - Manifests provided by new line delimiter", async () => { const kubectlVersion = 'v1.18.0' coreMock.getInput = jest.fn().mockImplementation((name) => { if (name == 'manifests') { - return "bg-smi.yml\nbg.yml\ndeployment.yml"; + return "bg-smi.yml\n bg.yml\ndeployment.yml"; } if (name == 'action') { return 'deploy'; @@ -235,7 +256,7 @@ test("run() - deploy - Manifests provided by comma as a delimiter", async () => const kubectlVersion = 'v1.18.0' coreMock.getInput = jest.fn().mockImplementation((name) => { if (name == 'manifests') { - return "bg-smi.yml,bg.yml,deployment.yml"; + return "bg-smi.yml, bg.yml, deployment.yml"; } if (name == 'action') { return 'deploy'; diff --git a/src/input-parameters.ts b/src/input-parameters.ts index 3f9a09ef..166541db 100644 --- a/src/input-parameters.ts +++ b/src/input-parameters.ts @@ -5,7 +5,7 @@ import * as core from '@actions/core'; export let namespace: string = core.getInput('namespace'); export const containers: string[] = core.getInput('images').split('\n'); export const imagePullSecrets: string[] = core.getInput('imagepullsecrets').split('\n').filter(secret => secret.trim().length > 0); -export const manifests = core.getInput('manifests').split(/[\n,]+/); +export const manifests = core.getInput('manifests').split(/[\n,]+/).filter(manifest => manifest.trim().length > 0); export const canaryPercentage: string = core.getInput('percentage'); export const deploymentStrategy: string = core.getInput('strategy'); export const trafficSplitMethod: string = core.getInput('traffic-split-method');