mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
allow to call KubeApi.delete without namespace parameter (#4349)
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
53dd538350
commit
385de469ad
@ -245,17 +245,40 @@ describe("KubeApi", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("sends correct request", async () => {
|
it("sends correct request with empty namespace", async () => {
|
||||||
|
expect.hasAssertions();
|
||||||
|
(fetch as any).mockResponse(async (request: Request) => {
|
||||||
|
expect(request.method).toEqual("DELETE");
|
||||||
|
expect(request.url).toEqual("http://127.0.0.1:9999/api-kube/api/v1/pods/foo?propagationPolicy=Background");
|
||||||
|
|
||||||
|
return {};
|
||||||
|
});
|
||||||
|
|
||||||
|
await api.delete({ name: "foo", namespace: "" });
|
||||||
|
});
|
||||||
|
|
||||||
|
it("sends correct request without namespace", async () => {
|
||||||
expect.hasAssertions();
|
expect.hasAssertions();
|
||||||
(fetch as any).mockResponse(async (request: Request) => {
|
(fetch as any).mockResponse(async (request: Request) => {
|
||||||
console.log(request.url);
|
|
||||||
expect(request.method).toEqual("DELETE");
|
expect(request.method).toEqual("DELETE");
|
||||||
expect(request.url).toEqual("http://127.0.0.1:9999/api-kube/api/v1/namespaces/default/pods/foo?propagationPolicy=Background");
|
expect(request.url).toEqual("http://127.0.0.1:9999/api-kube/api/v1/namespaces/default/pods/foo?propagationPolicy=Background");
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
});
|
});
|
||||||
|
|
||||||
await api.delete({ name: "foo", namespace: "default" });
|
await api.delete({ name: "foo" });
|
||||||
|
});
|
||||||
|
|
||||||
|
it("sends correct request with namespace", async () => {
|
||||||
|
expect.hasAssertions();
|
||||||
|
(fetch as any).mockResponse(async (request: Request) => {
|
||||||
|
expect(request.method).toEqual("DELETE");
|
||||||
|
expect(request.url).toEqual("http://127.0.0.1:9999/api-kube/api/v1/namespaces/kube-system/pods/foo?propagationPolicy=Background");
|
||||||
|
|
||||||
|
return {};
|
||||||
|
});
|
||||||
|
|
||||||
|
await api.delete({ name: "foo", namespace: "kube-system" });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("allows to change propagationPolicy", async () => {
|
it("allows to change propagationPolicy", async () => {
|
||||||
|
|||||||
@ -504,7 +504,7 @@ export class KubeApi<T extends KubeObject> {
|
|||||||
return parsed;
|
return parsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
async delete({ name = "", namespace = "default", propagationPolicy = "Background" }: { name: string, namespace: string, propagationPolicy?: PropagationPolicy }) {
|
async delete({ name = "", namespace = "default", propagationPolicy = "Background" }: { name: string, namespace?: string, propagationPolicy?: PropagationPolicy }) {
|
||||||
await this.checkPreferredVersion();
|
await this.checkPreferredVersion();
|
||||||
const apiUrl = this.getUrl({ namespace, name });
|
const apiUrl = this.getUrl({ namespace, name });
|
||||||
const reqInit = {
|
const reqInit = {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user