-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(k8s): correct
0.12 => 0.13
service resource conversion (#5272)
- Loading branch information
1 parent
946e74b
commit bfdd0af
Showing
3 changed files
with
93 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
core/test/unit/src/plugins/kubernetes/kubernetes-type/common.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (C) 2018-2023 Garden Technologies, Inc. <[email protected]> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
import { KubernetesTargetResourceSpec, ServiceResourceSpec } from "../../../../../../src/plugins/kubernetes/config" | ||
import { convertServiceResourceSpec } from "../../../../../../src/plugins/kubernetes/kubernetes-type/common" | ||
import { expect } from "chai" | ||
|
||
describe("convertServiceResource", () => { | ||
const moduleName = "module-a" | ||
|
||
it("picks kind and name if podSelector is not defined", async () => { | ||
const serviceResourceSpec: ServiceResourceSpec = { | ||
kind: "Deployment", | ||
name: "service-a", | ||
} | ||
|
||
const kubernetesResourceSpec = convertServiceResourceSpec(serviceResourceSpec, moduleName) | ||
const expectedKubernetesResourceSpec: KubernetesTargetResourceSpec = { | ||
kind: "Deployment", | ||
name: "service-a", | ||
} | ||
expect(kubernetesResourceSpec).to.eql(expectedKubernetesResourceSpec) | ||
}) | ||
|
||
it("picks kind and name if podSelector is empty", async () => { | ||
const serviceResourceSpec: ServiceResourceSpec = { | ||
kind: "Deployment", | ||
name: "service-a", | ||
podSelector: {}, | ||
} | ||
|
||
const kubernetesResourceSpec = convertServiceResourceSpec(serviceResourceSpec, moduleName) | ||
const expectedKubernetesResourceSpec: KubernetesTargetResourceSpec = { | ||
kind: "Deployment", | ||
name: "service-a", | ||
} | ||
expect(kubernetesResourceSpec).to.eql(expectedKubernetesResourceSpec) | ||
}) | ||
|
||
it("picks podSelector instead of kind and name if podSelector is not empty", async () => { | ||
const serviceResourceSpec: ServiceResourceSpec = { | ||
kind: "Deployment", | ||
name: "service-a", | ||
podSelector: { | ||
app: "app-service-a", | ||
}, | ||
} | ||
|
||
const kubernetesResourceSpec = convertServiceResourceSpec(serviceResourceSpec, moduleName) | ||
const expectedKubernetesResourceSpec: KubernetesTargetResourceSpec = { | ||
podSelector: { | ||
app: "app-service-a", | ||
}, | ||
} | ||
expect(kubernetesResourceSpec).to.eql(expectedKubernetesResourceSpec) | ||
}) | ||
}) |