forked from CycloneDX/cdxgen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker.test.js
75 lines (71 loc) · 1.77 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
72
73
74
75
import {
getConnection,
parseImageName,
getImage,
removeImage,
exportImage
} from "./docker";
import { expect, test } from "@jest/globals";
test("docker connection", async () => {
const dockerConn = await getConnection();
expect(dockerConn);
});
test("parseImageName tests", () => {
expect(parseImageName("debian")).toEqual({
registry: "",
repo: "debian",
tag: "",
digest: "",
platform: ""
});
expect(parseImageName("debian:latest")).toEqual({
registry: "",
repo: "debian",
tag: "latest",
digest: "",
platform: ""
});
expect(parseImageName("shiftleft/scan:v1.15.6")).toEqual({
registry: "",
repo: "shiftleft/scan",
tag: "v1.15.6",
digest: "",
platform: ""
});
expect(parseImageName("localhost:5000/shiftleft/scan:v1.15.6")).toEqual({
registry: "localhost:5000",
repo: "shiftleft/scan",
tag: "v1.15.6",
digest: "",
platform: ""
});
expect(parseImageName("localhost:5000/shiftleft/scan")).toEqual({
registry: "localhost:5000",
repo: "shiftleft/scan",
tag: "",
digest: "",
platform: ""
});
expect(
parseImageName(
"quay.io/shiftleft/scan-java@sha256:5d008306a7c5d09ba0161a3408fa3839dc2c9dd991ffb68adecc1040399fe9e1"
)
).toEqual({
registry: "quay.io",
repo: "shiftleft/scan-java",
tag: "",
digest: "5d008306a7c5d09ba0161a3408fa3839dc2c9dd991ffb68adecc1040399fe9e1",
platform: ""
});
});
test("docker getImage", async () => {
const imageData = await getImage("hello-world:latest");
if (imageData) {
const removeData = await removeImage("hello-world:latest");
expect(removeData);
}
}, 120000);
test("docker getImage", async () => {
const imageData = await exportImage("hello-world:latest");
expect(imageData);
}, 120000);