forked from CycloneDX/cdxgen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker.test.js
71 lines (67 loc) · 1.8 KB
/
docker.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
const dockerLib = require("./docker");
test("docker connection", async () => {
const dockerConn = await dockerLib.getConnection();
expect(dockerConn);
});
test("parseImageName tests", () => {
expect(dockerLib.parseImageName("debian")).toEqual({
registry: "",
repo: "debian",
tag: "",
digest: "",
platform: "",
});
expect(dockerLib.parseImageName("debian:latest")).toEqual({
registry: "",
repo: "debian",
tag: "latest",
digest: "",
platform: "",
});
expect(dockerLib.parseImageName("shiftleft/scan:v1.15.6")).toEqual({
registry: "",
repo: "shiftleft/scan",
tag: "v1.15.6",
digest: "",
platform: "",
});
expect(
dockerLib.parseImageName("localhost:5000/shiftleft/scan:v1.15.6")
).toEqual({
registry: "localhost:5000",
repo: "shiftleft/scan",
tag: "v1.15.6",
digest: "",
platform: "",
});
expect(dockerLib.parseImageName("localhost:5000/shiftleft/scan")).toEqual({
registry: "localhost:5000",
repo: "shiftleft/scan",
tag: "",
digest: "",
platform: "",
});
expect(
dockerLib.parseImageName(
"quay.io/shiftleft/scan-java@sha256:5d008306a7c5d09ba0161a3408fa3839dc2c9dd991ffb68adecc1040399fe9e1"
)
).toEqual({
registry: "quay.io",
repo: "shiftleft/scan-java",
tag: "",
digest: "5d008306a7c5d09ba0161a3408fa3839dc2c9dd991ffb68adecc1040399fe9e1",
platform: "",
});
});
test("docker getImage", async () => {
jest.setTimeout(120000);
const imageData = await dockerLib.getImage("hello-world:latest");
expect(imageData);
const removeData = await dockerLib.removeImage("hello-world:latest");
expect(removeData);
});
test("docker getImage", async () => {
jest.setTimeout(120000);
const imageData = await dockerLib.exportImage("hello-world:latest");
expect(imageData);
});