Add some basic unit tests for the following files: (#1050)

* Add some basic unit tests for cluster, kube-auth-proxy, and kubeconfig-manager

- src/main/cluster.ts
- src/main/kube-auth-proxy.ts
- src/main/kubeconfig-manager.ts

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton authored and GitHub committed 2020-10-09 11:25:20 -04:00
1 parent abe6a4e0b1
commit 0960259279
9 files changed
+651 -224

No files matched your search

+13 -4
View File
@@ -11,8 +11,12 @@ export class KubeconfigManager {
protected configDir = app.getPath("temp")
protected tempFile: string;
constructor(protected cluster: Cluster, protected contextHandler: ContextHandler, protected port: number) {
this.init();
private constructor(protected cluster: Cluster, protected contextHandler: ContextHandler, protected port: number) { }
static async create(cluster: Cluster, contextHandler: ContextHandler, port: number) {
const kcm = new KubeconfigManager(cluster, contextHandler, port)
await kcm.init()
return kcm
}
protected async init() {
@@ -72,8 +76,13 @@ export class KubeconfigManager {
return tempFile;
}
unlink() {
async unlink() {
if (!this.tempFile) {
return
}
logger.info('Deleting temporary kubeconfig: ' + this.tempFile)
fs.unlinkSync(this.tempFile)
await fs.unlink(this.tempFile)
this.tempFile = undefined
}
}