Skip to content

Commit

Permalink
sped up rating tool
Browse files Browse the repository at this point in the history
  • Loading branch information
rtjord committed Dec 8, 2024
1 parent 231138f commit 5a8eac4
Show file tree
Hide file tree
Showing 16 changed files with 165 additions and 141 deletions.
4 changes: 2 additions & 2 deletions backend/src/common/__tests__/zip.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ describe("File Operations and Compression Functions", () => {

describe("cloneAndZipRepository", () => {
it("should clone a repository and zip it", async () => {
const repoUrl = "https://github.com/isomorphic-git/isomorphic-git"; // Use a real repo URL
const repoUrl = "https://github.com/thejoshwolfe/yazl"; // Use a real repo URL
const zipBuffer = await cloneAndZipRepository(repoUrl);

const zip = await JSZip.loadAsync(zipBuffer);
const files = Object.keys(zip.files);

expect(files).toContain("README.md");
});
}, 60000);
});

describe("zipDirectory", () => {
Expand Down
1 change: 1 addition & 0 deletions backend/src/handlers/RegistryReset/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { APIGatewayProxyHandler } from "aws-lambda";
import { S3Client } from "@aws-sdk/client-s3";
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { DynamoDBDocumentClient } from "@aws-sdk/lib-dynamodb";

const commonPath = process.env.COMMON_PATH || '/opt/nodejs/common';
const { getEnvVariable } = require(`${commonPath}/utils`);
const { clearDynamoDBTable } = require(`${commonPath}/dynamodb`);
Expand Down
4 changes: 2 additions & 2 deletions backend/src/handlers/__tests__/end_to_end/getCost.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe("E2E Test for Get Cost Endpoint", () => {
let circular2_id: string;
beforeAll(async () => {
// Reset the registry before running the tests
await axios.delete(`${baseUrl}/reset`);
await axios.delete(`${baseUrl}/reset`, { timeout: 60000 });

// Upload yazl to the registry
const requestBody: PackageData = {
Expand Down Expand Up @@ -59,7 +59,7 @@ describe("E2E Test for Get Cost Endpoint", () => {
}, 90000);
afterAll(async () => {
// Reset the registry after running the tests
await axios.delete(`${baseUrl}/reset`);
await axios.delete(`${baseUrl}/reset`, { timeout: 60000 });
}, timeout);

it("should only return total cost if dependency is false", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe("E2E Test for Package By Name Endpoint", () => {
let id: string;
beforeAll(async () => {
// Reset the registry before running the tests
await axios.delete(`${baseUrl}/reset`);
await axios.delete(`${baseUrl}/reset`, { timeout: 60000 });

// Upload a package with Content to the registry
const requestBody: PackageData = {
Expand Down Expand Up @@ -43,7 +43,7 @@ describe("E2E Test for Package By Name Endpoint", () => {
}, 90000);
afterAll(async () => {
// Reset the registry after running the tests
await axios.delete(`${baseUrl}/reset`);
await axios.delete(`${baseUrl}/reset`, { timeout: 60000 });
}, 90000);

it("should return a 200 status for a package that exists", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe("E2E Test for PackageByRegEx Endpoint", () => {
let url_id: string;
beforeAll(async () => {
// Reset the registry before running the tests
await axios.delete(`${baseUrl}/reset`);
await axios.delete(`${baseUrl}/reset`, { timeout: 60000 });

// Upload a package with Content to the registry
const requestBody: PackageData = {
Expand Down Expand Up @@ -41,7 +41,7 @@ describe("E2E Test for PackageByRegEx Endpoint", () => {
}, 90000);
afterAll(async () => {
// Reset the registry after running the tests
await axios.delete(`${baseUrl}/reset`);
await axios.delete(`${baseUrl}/reset`, { timeout: 60000 });
}, 90000);

it("should return a 200 status for a package that exists", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ describe("E2E Test for Package Create Endpoint", () => {

beforeAll(async () => {
// Reset the registry before running the tests
await axios.delete(`${baseUrl}/reset`);
await axios.delete(`${baseUrl}/reset`, { timeout: 60000 });
}, timeout);
afterAll(async () => {
// Reset the registry after running the tests
await axios.delete(`${baseUrl}/reset`);
await axios.delete(`${baseUrl}/reset`, { timeout: 60000 });
}, timeout);
it("should return a 201 status for a package with Content set", async () => {
const requestBody: PackageData = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe("E2E Test for Package Delete Endpoint", () => {
let url_id: string;
beforeAll(async () => {
// Reset the registry before running the tests
await axios.delete(`${baseUrl}/reset`);
await axios.delete(`${baseUrl}/reset`, { timeout: 60000 });

// Upload a package with Content to the registry
const requestBody: PackageData = {
Expand Down Expand Up @@ -39,7 +39,7 @@ describe("E2E Test for Package Delete Endpoint", () => {
}, 90000);
afterAll(async () => {
// Reset the registry after running the tests
await axios.delete(`${baseUrl}/reset`);
await axios.delete(`${baseUrl}/reset`, { timeout: 60000 });
}, timeout);

it("should return a 200 status for a package uploaded via Content", async () => {
Expand Down
4 changes: 2 additions & 2 deletions backend/src/handlers/__tests__/end_to_end/packageRate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe("E2E Test for Package Rate Endpoint", () => {
let url_id: string;
beforeAll(async () => {
// Reset the registry before running the tests
await axios.delete(`${baseUrl}/reset`);
await axios.delete(`${baseUrl}/reset`, { timeout: 60000 });

// Upload a package with Content to the registry
const requestBody: PackageData = {
Expand Down Expand Up @@ -39,7 +39,7 @@ describe("E2E Test for Package Rate Endpoint", () => {
}, 90000);
afterAll(async () => {
// Reset the registry after running the tests
await axios.delete(`${baseUrl}/reset`);
await axios.delete(`${baseUrl}/reset`, { timeout: 60000 });
}, timeout);

it("should return a 200 status for a package with a rating", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,17 @@ async function upload(name: string, url: string) {
URL: url,
debloat: false
};

console.log("Uploading package: ", name);
await axios.post(`${baseUrl}/package`, requestBody);
}

describe("E2E Test for PackageRecommend Endpoint", () => {
beforeAll(async () => {
// Reset the registry before running the tests
await axios.delete(`${baseUrl}/reset`);
await axios.delete(`${baseUrl}/reset`, { timeout: 60000 });

// Upload packages to the registry
await upload("yazl", "https://www.npmjs.com/package/yazl");
await upload("express", "https://www.npmjs.com/package/express");
await upload("debug", "https://www.npmjs.com/package/debug");
await upload("inversify", "https://www.npmjs.com/package/inversify");
await upload("tslib", "https://www.npmjs.com/package/tslib");
Expand All @@ -33,7 +32,7 @@ describe("E2E Test for PackageRecommend Endpoint", () => {
}, 90000);
afterAll(async () => {
// Reset the registry after running the tests
await axios.delete(`${baseUrl}/reset`);
await axios.delete(`${baseUrl}/reset`, { timeout: 60000 });
}, 90000);

it("should return a list of 5 packages with express as the first", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe("E2E Test for Package Retrieve Endpoint", () => {
let url_id: string;
beforeAll(async () => {
// Reset the registry before running the tests
await axios.delete(`${baseUrl}/reset`);
await axios.delete(`${baseUrl}/reset`, { timeout: 60000 });

// Upload a package with Content to the registry
const requestBody: PackageData = {
Expand Down Expand Up @@ -39,7 +39,7 @@ describe("E2E Test for Package Retrieve Endpoint", () => {
}, 90000);
afterAll(async () => {
// Reset the registry after running the tests
await axios.delete(`${baseUrl}/reset`);
await axios.delete(`${baseUrl}/reset`, { timeout: 60000 });
}, timeout);

it("should return a 200 status for a package uploaded via Content", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe("E2E Test for Package Update Endpoint", () => {
let url_id: string;
beforeAll(async () => {
// Reset the registry before running the tests
await axios.delete(`${baseUrl}/reset`);
await axios.delete(`${baseUrl}/reset`, { timeout: 60000 });

// Upload a package with Content to the registry
const requestBody: PackageData = {
Expand Down Expand Up @@ -38,7 +38,7 @@ describe("E2E Test for Package Update Endpoint", () => {
}, 60000);
afterAll(async () => {
// Reset the registry after running the tests
await axios.delete(`${baseUrl}/reset`);
await axios.delete(`${baseUrl}/reset`, { timeout: 60000 });
}, timeout);
it("should return a 200 status for a package with Content set", async () => {
const requestBody: Package = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe("E2E Test for Packages List Endpoint", () => {
const ids: string[] = [];
beforeAll(async () => {
// Reset the registry before running the tests
await axios.delete(`${baseUrl}/reset`);
await axios.delete(`${baseUrl}/reset`, { timeout: 60000 });

// Upload a package with Content to the registry
const requestBody: PackageData = {
Expand Down Expand Up @@ -47,7 +47,7 @@ describe("E2E Test for Packages List Endpoint", () => {
}, 240000);
afterAll(async () => {
// Reset the registry after running the tests
await axios.delete(`${baseUrl}/reset`);
await axios.delete(`${baseUrl}/reset`, { timeout: 60000 });
}, timeout);

it("should fetch all packages and return 200 status", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { baseUrl } from "./config";
const timeout = 30000;
describe("E2E Test for Registry Reset Endpoint", () => {
it("should return a 200 status", async () => {
const response = await axios.delete(`${baseUrl}/reset`);
const response = await axios.delete(`${baseUrl}/reset`, { timeout: 60000 });
expect(response.status).toBe(200);
}, timeout);
});
Loading

0 comments on commit 5a8eac4

Please sign in to comment.