Skip to content
This repository was archived by the owner on Oct 14, 2020. It is now read-only.

Commit 8307fd9

Browse files
committed
# 21 Autoformat helpers.js
1 parent f384d04 commit 8307fd9

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

tests/integration/helpers.js

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ const k8sBatchApi = kc.makeApiClient(k8s.BatchV1Api);
88

99
const namespace = "integration-tests";
1010

11-
const sleep = duration =>
12-
new Promise(resolve => setTimeout(resolve, duration * 1000));
11+
const sleep = (duration) =>
12+
new Promise((resolve) => setTimeout(resolve, duration * 1000));
1313

1414
async function deleteScan(name) {
1515
await k8sCRDApi.deleteNamespacedCustomObject(
@@ -30,21 +30,18 @@ async function getScan(name) {
3030
"scans",
3131
name
3232
);
33-
return scan
33+
return scan;
3434
}
3535

3636
async function logJob(name) {
3737
try {
38-
const { body: job } = await k8sBatchApi.readNamespacedJob(
39-
name,
40-
namespace,
41-
);
42-
console.log(`Job: '${name}' Spec:`)
43-
console.dir(job.spec)
44-
console.log(`Job: '${name}' Status:`)
45-
console.dir(job.status)
38+
const { body: job } = await k8sBatchApi.readNamespacedJob(name, namespace);
39+
console.log(`Job: '${name}' Spec:`);
40+
console.dir(job.spec);
41+
console.log(`Job: '${name}' Status:`);
42+
console.dir(job.status);
4643
} catch (error) {
47-
console.info(`Job: '${name} not found.'`)
44+
console.info(`Job: '${name} not found.'`);
4845
}
4946
}
5047

@@ -61,12 +58,12 @@ async function scan(name, scanType, parameters = [], timeout = 180) {
6158
kind: "Scan",
6259
metadata: {
6360
// Use `generateName` instead of name to generate a random sufix and avoid name clashes
64-
generateName: `${name}-`
61+
generateName: `${name}-`,
6562
},
6663
spec: {
6764
scanType,
68-
parameters
69-
}
65+
parameters,
66+
},
7067
};
7168

7269
const { body } = await k8sCRDApi.createNamespacedCustomObject(
@@ -82,25 +79,27 @@ async function scan(name, scanType, parameters = [], timeout = 180) {
8279
for (let i = 0; i < timeout; i++) {
8380
await sleep(1);
8481
const { status } = await getScan(actualName);
85-
82+
8683
if (status && status.state === "Done") {
8784
await deleteScan(actualName);
8885
return status.findings;
8986
} else if (status && status.state === "Errored") {
9087
await deleteScan(actualName);
91-
throw new Error(`Scan failed with description "${status.errorDescription}"`)
88+
throw new Error(
89+
`Scan failed with description "${status.errorDescription}"`
90+
);
9291
}
9392
}
94-
95-
console.error("Scan Timed out!")
93+
94+
console.error("Scan Timed out!");
9695

9796
const scan = await getScan(actualName);
98-
console.log("Last Scan State:")
99-
console.dir(scan)
100-
await logJob(`scan-${actualName}`)
101-
await logJob(`parse-${actualName}`)
97+
console.log("Last Scan State:");
98+
console.dir(scan);
99+
await logJob(`scan-${actualName}`);
100+
await logJob(`parse-${actualName}`);
102101

103102
throw new Error("timed out while waiting for scan results");
104103
}
105104

106-
module.exports.scan = scan;
105+
module.exports.scan = scan;

0 commit comments

Comments
 (0)