mirror of
https://github.com/Azure/k8s-deploy.git
synced 2026-04-12 17:42:20 +08:00
Tests fixed
This commit is contained in:
parent
bfca26e368
commit
faf09632f3
@ -38,7 +38,7 @@ const getAllPodsMock = {
|
|||||||
|
|
||||||
const getNamespaceMock = {
|
const getNamespaceMock = {
|
||||||
'code': 0,
|
'code': 0,
|
||||||
'stdout': '{"apiVersion": "v1","kind": "Namespace","metadata": {"annotations": {"githubWorkflow_c11401b9d232942bac19cbc5bc32b42d": "{\'run\': \'202489005\',\'repository\': \'testUser/hello-kubernetes\',\'workflow\': \'workflow1\',\'jobName\': \'build-and-deploy\',\'createdBy\': \'testUser\',\'runUri\': \'https://github.com/testUser/hello-kubernetes/actions/runs/202489005\',\'commit\': \'currentCommit\',\'lastSuccessRunCommit\': \'lastCommit\',\'branch\': \'refs/heads/branch-rename\',\'deployTimestamp\': \'1597062957973\',\'provider\': \'GitHub\'}","githubWorkflow_21fd7a597282ca5adc05ba99018b3706": "{\'run\': \'202504411\',\'repository\': \'testUser/hello-kubernetes\',\'workflow\': \'workflowMaster\',\'jobName\': \'build-and-deploy\',\'createdBy\': \'testUser\',\'runUri\': \'https://github.com/testUser/hello-kubernetes/actions/runs/202504411\',\'commit\': \'currentCommit1\',\'lastSuccessRunCommit\': \'NA\',\'branch\': \'refs/heads/master\',\'deployTimestamp\': \'1597063919873\',\'provider\': \'GitHub\'}"}},"spec": {"finalizers": ["kubernetes"]},"status": {"phase": "Active"}}'
|
'stdout': '{"apiVersion": "v1","kind": "Namespace","metadata": {"annotations": {"githubWorkflow_c11401b9d232942bac19cbc5bc32b42d": "{\'run\': \'202489005\',\'repository\': \'testUser/hello-kubernetes\',\'workflow\': \'workflow1\',\'jobName\': \'build-and-deploy\',\'createdBy\': \'testUser\',\'runUri\': \'https://github.com/testUser/hello-kubernetes/actions/runs/202489005\',\'commit\': \'currentCommit\',\'lastSuccessRunCommit\': \'lastCommit\',\'branch\': \'refs/heads/branch-rename\',\'deployTimestamp\': \'1597062957973\',\'filePathConfigs\': \'{}\',\'provider\': \'GitHub\'}","githubWorkflow_21fd7a597282ca5adc05ba99018b3706": "{\'run\': \'202504411\',\'repository\': \'testUser/hello-kubernetes\',\'workflow\': \'workflowMaster\',\'jobName\': \'build-and-deploy\',\'createdBy\': \'testUser\',\'runUri\': \'https://github.com/testUser/hello-kubernetes/actions/runs/202504411\',\'commit\': \'currentCommit1\',\'lastSuccessRunCommit\': \'NA\',\'branch\': \'refs/heads/master\',\'deployTimestamp\': \'1597063919873\',\'filePathConfigs\': \'{}\',\'provider\': \'GitHub\'}"}},"spec": {"finalizers": ["kubernetes"]},"status": {"phase": "Active"}}'
|
||||||
};
|
};
|
||||||
|
|
||||||
const getWorkflowsUrlResponse = {
|
const getWorkflowsUrlResponse = {
|
||||||
@ -293,7 +293,8 @@ test("deployment - deploy() - deploy force flag on", async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("deployment - deploy() - Annotate & label resources", async () => {
|
test("deployment - deploy() - Annotate & label resources", async () => {
|
||||||
let annotationKeyValStr = getWorkflowAnnotationKeyLabel(process.env.GITHUB_WORKFLOW) + '=' + getWorkflowAnnotationsJson('currentCommit', '.github/workflows/workflow.yml');
|
let filepathConfigs = { manifestFilePaths :['manifests/deployment.yaml'], helmChartFilePaths : '', buildConfigs :{}} ;
|
||||||
|
let annotationKeyValStr = getWorkflowAnnotationKeyLabel(process.env.GITHUB_WORKFLOW) + '=' + getWorkflowAnnotationsJson('currentCommit', '.github/workflows/workflow.yml', filepathConfigs);
|
||||||
const KubernetesManifestUtilityMock = mocked(KubernetesManifestUtility, true);
|
const KubernetesManifestUtilityMock = mocked(KubernetesManifestUtility, true);
|
||||||
KubernetesManifestUtilityMock.checkManifestStability = jest.fn().mockReturnValue("");
|
KubernetesManifestUtilityMock.checkManifestStability = jest.fn().mockReturnValue("");
|
||||||
const KubernetesObjectUtilityMock = mocked(KubernetesObjectUtility, true);
|
const KubernetesObjectUtilityMock = mocked(KubernetesObjectUtility, true);
|
||||||
@ -301,6 +302,7 @@ test("deployment - deploy() - Annotate & label resources", async () => {
|
|||||||
const fileHelperMock = mocked(fileHelper, true);
|
const fileHelperMock = mocked(fileHelper, true);
|
||||||
fileHelperMock.writeObjectsToFile = jest.fn().mockReturnValue(["~/Deployment_testapp_currentTimestamp"]);
|
fileHelperMock.writeObjectsToFile = jest.fn().mockReturnValue(["~/Deployment_testapp_currentTimestamp"]);
|
||||||
jest.spyOn(utility, 'getWorkflowFilePath').mockImplementation(() => Promise.resolve(process.env.GITHUB_WORKFLOW));
|
jest.spyOn(utility, 'getWorkflowFilePath').mockImplementation(() => Promise.resolve(process.env.GITHUB_WORKFLOW));
|
||||||
|
jest.spyOn(utility, 'getFilePathsConfigs').mockImplementation(()=> Promise.resolve(filepathConfigs));
|
||||||
|
|
||||||
const kubeCtl: jest.Mocked<Kubectl> = new Kubectl("") as any;
|
const kubeCtl: jest.Mocked<Kubectl> = new Kubectl("") as any;
|
||||||
kubeCtl.apply = jest.fn().mockReturnValue("");
|
kubeCtl.apply = jest.fn().mockReturnValue("");
|
||||||
@ -321,7 +323,8 @@ test("deployment - deploy() - Annotate & label resources", async () => {
|
|||||||
|
|
||||||
test("deployment - deploy() - Annotate & label resources for a new workflow", async () => {
|
test("deployment - deploy() - Annotate & label resources for a new workflow", async () => {
|
||||||
process.env.GITHUB_WORKFLOW = '.github/workflows/NewWorkflow.yml';
|
process.env.GITHUB_WORKFLOW = '.github/workflows/NewWorkflow.yml';
|
||||||
let annotationKeyValStr = getWorkflowAnnotationKeyLabel(process.env.GITHUB_WORKFLOW) + '=' + getWorkflowAnnotationsJson('NA', '.github/workflows/NewWorkflow.yml');
|
let filepathConfigs = { manifestFilePaths :['manifests/deployment.yaml'], helmChartFilePaths : '', buildConfigs :{}} ;
|
||||||
|
let annotationKeyValStr = getWorkflowAnnotationKeyLabel(process.env.GITHUB_WORKFLOW) + '=' + getWorkflowAnnotationsJson('NA', '.github/workflows/NewWorkflow.yml', filepathConfigs);
|
||||||
const KubernetesManifestUtilityMock = mocked(KubernetesManifestUtility, true);
|
const KubernetesManifestUtilityMock = mocked(KubernetesManifestUtility, true);
|
||||||
KubernetesManifestUtilityMock.checkManifestStability = jest.fn().mockReturnValue("");
|
KubernetesManifestUtilityMock.checkManifestStability = jest.fn().mockReturnValue("");
|
||||||
const KubernetesObjectUtilityMock = mocked(KubernetesObjectUtility, true);
|
const KubernetesObjectUtilityMock = mocked(KubernetesObjectUtility, true);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user