Skip to content

Commit 4832654

Browse files
committed
Replaced the upload function in global setup with a reusable function that returns SBOM IDs.
Signed-off-by: Vilem Obratil <[email protected]>
1 parent 70ad74b commit 4832654

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

e2e/tests/api/dependencies/global.setup.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
SETUP_TIMEOUT,
1111
} from "../../common/constants";
1212
import { test as setup } from "../fixtures";
13+
import { uploadSboms } from "../helpers/upload";
1314

1415
setup.describe("Ingest initial data", () => {
1516
setup.skip(
@@ -21,26 +22,12 @@ setup.describe("Ingest initial data", () => {
2122
setup.setTimeout(SETUP_TIMEOUT);
2223

2324
logger.info("Setup: start uploading assets");
24-
await uploadSboms(axios, SBOM_FILES);
25+
await uploadSboms(axios, SBOM_FILES, "../../common/assets/sbom/");
2526
await uploadAdvisories(axios, ADVISORY_FILES);
2627
logger.info("Setup: upload finished successfully");
2728
});
2829
});
2930

30-
const uploadSboms = async (axios: AxiosInstance, files: string[]) => {
31-
const uploads = files.map((e) => {
32-
const filePath = path.join(__dirname, `../../common/assets/sbom/${e}`);
33-
fs.statSync(filePath); // Verify file exists
34-
35-
const fileStream = fs.createReadStream(filePath);
36-
return axios.post("/api/v2/sbom", fileStream, {
37-
headers: { "Content-Type": "application/json+bzip2" },
38-
});
39-
});
40-
41-
await Promise.all(uploads);
42-
};
43-
4431
const uploadAdvisories = async (axios: AxiosInstance, files: string[]) => {
4532
const uploads = files.map((e) => {
4633
const filePath = path.join(__dirname, `../../common/assets/csaf/${e}`);

0 commit comments

Comments
 (0)