Skip to content

Commit

Permalink
replicaset tests
Browse files Browse the repository at this point in the history
  • Loading branch information
busma13 committed Sep 17, 2024
1 parent 927d641 commit 62c1c02
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ describe('k8s', () => {
const jobs = await k8s.list('app=teraslice', 'jobs');
expect(jobs.kind).toEqual('JobList');
});

it('can get ReplicaSetList', async () => {
nock(_url)
.get('/apis/apps/v1/namespaces/default/replicasets/')
.query({ labelSelector: 'app=teraslice' })
.reply(200, { kind: 'ReplicaSetList' });

const jobs = await k8s.list('app=teraslice', 'replicasets');
expect(jobs.kind).toEqual('ReplicaSetList');
});
});

describe('->nonEmptyList', () => {
Expand Down Expand Up @@ -216,6 +226,15 @@ describe('k8s', () => {
expect(response).toEqual({});
});

it('can delete a replicaset by name', async () => {
nock(_url)
.delete('/apis/apps/v1/namespaces/default/replicasets/test1')
.reply(200, {});

const response = await k8s.delete('test1', 'replicasets');
expect(response).toEqual({});
});

it('will throw on a reponse code >= 400, excluding 404', async () => {
nock(_url)
.delete('/api/v1/namespaces/default/pods/bad-response')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ describe('k8s', () => {
const jobs = await k8s.list('app=teraslice', 'jobs');
expect(jobs.kind).toEqual('JobList');
});

it('can get ReplicaSetList', async () => {
nock(_url)
.get('/apis/apps/v1/namespaces/default/replicasets')
.query({ labelSelector: 'app=teraslice' })
.reply(200, { kind: 'ReplicaSetList' });

const jobs = await k8s.list('app=teraslice', 'replicasets');
expect(jobs.kind).toEqual('ReplicaSetList');
});
});

describe('->nonEmptyList', () => {
Expand Down Expand Up @@ -227,6 +237,15 @@ describe('k8s', () => {
expect(response).toEqual({});
});

it('can delete a replicaset by name', async () => {
nock(_url)
.delete('/apis/apps/v1/namespaces/default/replicasets/test1')
.reply(200, {});

const response = await k8s.delete('test1', 'replicasets');
expect(response).toEqual({});
});

it('will throw on a reponse code >= 400, excluding 404', async () => {
nock(_url)
.delete('/api/v1/namespaces/default/pods/bad-response')
Expand Down

0 comments on commit 62c1c02

Please sign in to comment.