Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Unit Tests #63

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ var schemas = {
initGlobusDownload: {
type: "object",
properties: {
jobId: { type: "string"},
jobId: { type: "string" },
jupyterhubApiToken: { type: "string" },
toEndpoint: { type: "string" },
toPath: { type: "string" },
Expand Down
7 changes: 4 additions & 3 deletions test/TestHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import { Job } from "../src/models/Job";
export default class TestHelper {
static async createJob(
id: string,
userId: string,
secretToken: string,
jupyterhubApiToken: string,
maintainer: string,
hpc: string
hpc: string,
userId: string,
password: string
): Promise<Job> {
const db = new DB();
const connection = await db.connect();
Expand Down
6 changes: 3 additions & 3 deletions test/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};
preset: "ts-jest",
testEnvironment: "node",
};
45 changes: 26 additions & 19 deletions test/service/Emitter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ afterEach(async () => {

const jobId = "test-job";
const userId = "test-user";
const secretToken = "abcdefg";
const userPassword = "test-password";
const jupyterhubApiToken = "abcdefg";
const maintainer = "community_contribution";
const hpc = "keeling_community";

Expand All @@ -31,10 +32,11 @@ describe("test Emitter.getEvents", () => {
test("simple get event", async () => {
const job = await TestHelper.createJob(
jobId,
userId,
secretToken,
jupyterhubApiToken,
maintainer,
hpc
hpc,
userId,
userPassword
);
const createdEvent = await TestHelper.createEvent(
job,
Expand All @@ -53,10 +55,11 @@ describe("test Emitter.getEvents", () => {
const eventsCount = 10;
const job = await TestHelper.createJob(
jobId,
userId,
secretToken,
jupyterhubApiToken,
maintainer,
hpc
hpc,
userId,
userPassword
);
for (var i = 0; i < eventsCount; i++)
await TestHelper.createEvent(
Expand All @@ -80,10 +83,11 @@ describe("test Emitter.getLogs", () => {
test("simple get log", async () => {
const job = await TestHelper.createJob(
jobId,
userId,
secretToken,
jupyterhubApiToken,
maintainer,
hpc
hpc,
userId,
userPassword
);
const createdLog = await TestHelper.createLog(job, logMessage);
const queriedLogs = await emitter.getLogs(job.id);
Expand All @@ -98,10 +102,11 @@ describe("test Emitter.getLogs", () => {
const logsCount = 10;
const job = await TestHelper.createJob(
jobId,
userId,
secretToken,
jupyterhubApiToken,
maintainer,
hpc
hpc,
userId,
userPassword
);
for (var i = 0; i < logsCount; i++)
await TestHelper.createLog(job, `${logMessage}_${i}`);
Expand All @@ -121,10 +126,11 @@ describe("test Emitter.registerLogs", () => {
test("simple register log", async () => {
const job = await TestHelper.createJob(
jobId,
userId,
secretToken,
jupyterhubApiToken,
maintainer,
hpc
hpc,
userId,
userPassword
);
await emitter.registerLogs(job, `${logMessage}_register_${0}`);
await emitter.registerLogs(job, `${logMessage}_register_${1}`);
Expand All @@ -143,10 +149,11 @@ describe("test Emitter.registerEvents", () => {
test("simple register events", async () => {
const job = await TestHelper.createJob(
jobId,
userId,
secretToken,
jupyterhubApiToken,
maintainer,
hpc
hpc,
userId,
userPassword
);
await emitter.registerEvents(
job,
Expand Down