From 40d3bf5bb95a444c89f1a0da5c624d257c60e032 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Tue, 4 Oct 2022 15:19:51 -0400 Subject: [PATCH] Update tests Signed-off-by: Sebastian Malton --- ...wing-details-for-helm-release.test.ts.snap | 60 ------- .../get-helm-release-resources.injectable.ts | 1 - .../get-helm-release-resources.test.ts | 148 +----------------- 3 files changed, 3 insertions(+), 206 deletions(-) diff --git a/src/features/helm-releases/__snapshots__/showing-details-for-helm-release.test.ts.snap b/src/features/helm-releases/__snapshots__/showing-details-for-helm-release.test.ts.snap index a4159c60be..c45e3d30b6 100644 --- a/src/features/helm-releases/__snapshots__/showing-details-for-helm-release.test.ts.snap +++ b/src/features/helm-releases/__snapshots__/showing-details-for-helm-release.test.ts.snap @@ -5552,11 +5552,6 @@ exports[`showing details for helm release given application is started when navi > Namespace -
- Age -
some-namespace
-
- 0s -
@@ -6784,11 +6774,6 @@ exports[`showing details for helm release given application is started when navi > Namespace -
- Age -
some-namespace
-
- 0s -
@@ -8016,11 +7996,6 @@ exports[`showing details for helm release given application is started when navi > Namespace -
- Age -
some-namespace
-
- 0s -
@@ -9073,11 +9043,6 @@ exports[`showing details for helm release given application is started when navi > Namespace -
- Age -
some-namespace
-
- 0s -
@@ -10132,11 +10092,6 @@ exports[`showing details for helm release given application is started when navi > Namespace -
- Age -
some-namespace
-
- 0s -
@@ -11364,11 +11314,6 @@ exports[`showing details for helm release given application is started when navi > Namespace -
- Age -
some-namespace
-
- 0s -
diff --git a/src/main/helm/helm-service/get-helm-release-resources/get-helm-release-resources.injectable.ts b/src/main/helm/helm-service/get-helm-release-resources/get-helm-release-resources.injectable.ts index 4bc99461f9..ce5c60d6b3 100644 --- a/src/main/helm/helm-service/get-helm-release-resources/get-helm-release-resources.injectable.ts +++ b/src/main/helm/helm-service/get-helm-release-resources/get-helm-release-resources.injectable.ts @@ -11,7 +11,6 @@ export type GetHelmReleaseResources = ( name: string, namespace: string, kubeconfigPath: string, - kubectlPath: string ) => Promise>; const getHelmReleaseResourcesInjectable = getInjectable({ diff --git a/src/main/helm/helm-service/get-helm-release-resources/get-helm-release-resources.test.ts b/src/main/helm/helm-service/get-helm-release-resources/get-helm-release-resources.test.ts index d697095144..4d6ccda7b8 100644 --- a/src/main/helm/helm-service/get-helm-release-resources/get-helm-release-resources.test.ts +++ b/src/main/helm/helm-service/get-helm-release-resources/get-helm-release-resources.test.ts @@ -44,7 +44,6 @@ describe("get helm release resources", () => { "some-release", "some-namespace", "/some-kubeconfig-path", - "/some-kubectl-path", ); }); @@ -66,150 +65,9 @@ describe("get helm release resources", () => { const actual = await actualPromise; - expect(actual).toEqual([]); - }); - - describe("when call for manifest resolves", () => { - beforeEach(async () => { - await execHelmMock.resolve({ - callWasSuccessful: true, - response: `--- -apiVersion: v1 -kind: SomeKind -metadata: - name: some-resource-with-same-namespace - namespace: some-namespace ---- -apiVersion: v1 -kind: SomeKind -metadata: - name: some-resource-without-namespace ---- -apiVersion: v1 -kind: SomeKind -metadata: - name: some-resource-with-different-namespace - namespace: some-other-namespace ---- -`, - }); - }); - - it("calls for resources from each namespace separately using the manifest as input", () => { - expect(execFileWithStreamInputMock.mock.calls).toEqual([ - [ - { - filePath: "/some-kubectl-path", - commandArguments: ["get", "--kubeconfig", "/some-kubeconfig-path", "-f", "-", "--namespace", "some-namespace", "--output", "json"], - input: `--- -apiVersion: v1 -kind: SomeKind -metadata: - name: some-resource-with-same-namespace - namespace: some-namespace ---- -apiVersion: v1 -kind: SomeKind -metadata: - name: some-resource-without-namespace ---- -`, - }, - ], - - [ - { - filePath: "/some-kubectl-path", - commandArguments: ["get", "--kubeconfig", "/some-kubeconfig-path", "-f", "-", "--namespace", "some-other-namespace", "--output", "json"], - input: `--- -apiVersion: v1 -kind: SomeKind -metadata: - name: some-resource-with-different-namespace - namespace: some-other-namespace ---- -`, - }, - ], - ]); - }); - - it("when all calls for resources resolve, resolves with combined result", async () => { - await execFileWithStreamInputMock.resolveSpecific( - ([{ commandArguments }]) => - commandArguments.includes("some-namespace"), - { - callWasSuccessful: true, - - response: JSON.stringify({ - items: [{ some: "item" }], - - kind: "List", - - metadata: { - resourceVersion: "", - selfLink: "", - }, - }), - }, - ); - - await execFileWithStreamInputMock.resolveSpecific( - ([{ commandArguments }]) => - commandArguments.includes("some-other-namespace"), - { - callWasSuccessful: true, - - response: JSON.stringify({ - items: [{ some: "other-item" }], - - kind: "List", - - metadata: { - resourceVersion: "", - selfLink: "", - }, - }), - }, - ); - - const actual = await actualPromise; - - expect(actual).toEqual([{ some: "item" }, { some: "other-item" }]); - }); - - it("given some call fails, when all calls have finished, rejects with failure", async () => { - await execFileWithStreamInputMock.resolveSpecific( - ([{ commandArguments }]) => - commandArguments.includes("some-namespace"), - - { - callWasSuccessful: true, - - response: JSON.stringify({ - items: [{ some: "item" }], - - kind: "List", - - metadata: { - resourceVersion: "", - selfLink: "", - }, - }), - }, - ); - - execFileWithStreamInputMock.resolveSpecific( - ([{ commandArguments }]) => - commandArguments.includes("some-other-namespace"), - - { - callWasSuccessful: false, - error: "some-error", - }, - ); - - return expect(actualPromise).rejects.toEqual(expect.any(Error)); + expect(actual).toEqual({ + callWasSuccessful: true, + response: [], }); }); });