Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
Signed-off-by: Jeromy Cannon <jeromy@swirldslabs.com>
  • Loading branch information
jeromy-cannon committed Jan 24, 2024
1 parent d12877c commit 9446ce7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion fullstack-network-manager/src/commands/chart.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export class ChartCommand extends BaseCommand {
task: async (ctx, _) => {
if (ctx.config.pvcs) {
for (const pvc of ctx.config.pvcs) {
await self.k8.deletePvc(pvc.metadata.name, ctx.config.namespace)
await self.k8.deletePvc(pvc, ctx.config.namespace)
}
}
}
Expand Down
11 changes: 8 additions & 3 deletions fullstack-network-manager/src/core/k8.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -638,16 +638,21 @@ export class K8 {
}

/**
* Get a list of persistent volume claims by namespace
* Get a list of persistent volume claim names for the given namespace
* @param namespace the namespace of the persistent volume claims to return
* @returns {Promise<Array<V1PersistentVolumeClaim>>} list of persistent volume claims
* @returns {Promise<*[]>} list of persistent volume claims
*/
async listPvcsByNamespace (namespace) {
const pvcs = []
const resp = await this.kubeClient.listNamespacedPersistentVolumeClaim (
namespace
)

return resp.body.items
for (const item of resp.body.items) {
pvcs.push(item.metadata.name)
}

return pvcs
}

/**
Expand Down
5 changes: 5 additions & 0 deletions fullstack-network-manager/test/e2e/core/k8_e2e.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,9 @@ describe('K8', () => {

fs.rmdirSync(tmpDir, { recursive: true })
})

it('should be able to get two persistent volume claims', async () => {
const pvcs = await k8.listPvcsByNamespace(k8._getNamespace())
expect(pvcs).toHaveLength(2)
})
})

0 comments on commit 9446ce7

Please sign in to comment.