Skip to content

Commit 13dda33

Browse files
committed
indentation
1 parent 81163a2 commit 13dda33

File tree

3 files changed

+327
-327
lines changed

3 files changed

+327
-327
lines changed

__tests__/worker.ts

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,58 @@ import { ContainerInitialization } from "../src/types/worker";
22
import JobWorker from "../src/worker";
33

44
describe("Docker initialization test", () => {
5-
it("should create a python container", async () => {
6-
const worker = new JobWorker("python3", { code: "", functionName: "" });
7-
worker
8-
.createContainer()
9-
.then(({ error, containerID }) => {
10-
expect(error).toBe(false);
11-
expect(containerID).toBeTruthy;
12-
worker.removeContainer();
13-
})
14-
.catch((_) => {});
15-
});
5+
it("should create a python container", async () => {
6+
const worker = new JobWorker("python3", { code: "", functionName: "" });
7+
worker
8+
.createContainer()
9+
.then(({ error, containerID }) => {
10+
expect(error).toBe(false);
11+
expect(containerID).toBeTruthy;
12+
worker.removeContainer();
13+
})
14+
.catch((_) => {});
15+
});
1616

17-
// TODO write a tast case for writeFile() & copyContext
17+
// TODO write a tast case for writeFile() & copyContext
1818

19-
it("should not create a container", async () => {
20-
const worker = new JobWorker("invalidName" as any, {
21-
code: "",
22-
functionName: "",
23-
});
24-
worker
25-
.createContainer()
26-
.catch(
27-
({ error, containerID, errorMessage }: ContainerInitialization) => {
28-
expect(error).toBe(true);
29-
expect(containerID).toBeFalsy();
30-
expect(errorMessage).toBeTruthy();
31-
}
32-
);
33-
});
19+
it("should not create a container", async () => {
20+
const worker = new JobWorker("invalidName" as any, {
21+
code: "",
22+
functionName: "",
23+
});
24+
worker
25+
.createContainer()
26+
.catch(
27+
({ error, containerID, errorMessage }: ContainerInitialization) => {
28+
expect(error).toBe(true);
29+
expect(containerID).toBeFalsy();
30+
expect(errorMessage).toBeTruthy();
31+
}
32+
);
33+
});
3434

3535

36-
it("should not initialize a container", async () => {
37-
const worker = new JobWorker("invalidName" as any, { code: "print('Hello World!')", functionName: "" });
38-
worker
39-
.initContainer()
40-
.then(({ error, message }) => {
41-
expect(error).toBe(false);
42-
expect(message).toBe("Job has succedded.");
43-
worker.cleanupJob();
44-
})
45-
.catch((_) => {});
46-
});
36+
it("should not initialize a container", async () => {
37+
const worker = new JobWorker("invalidName" as any, { code: "print('Hello World!')", functionName: "" });
38+
worker
39+
.initContainer()
40+
.then(({ error, message }) => {
41+
expect(error).toBe(false);
42+
expect(message).toBe("Job has succedded.");
43+
worker.cleanupJob();
44+
})
45+
.catch((_) => {});
46+
});
4747

48-
it("should initialize a python container with code in it", async () => {
49-
const worker = new JobWorker("python3", { code: "print('Hello World!')", functionName: "" });
50-
worker
51-
.initContainer()
52-
.then(({ error, message }) => {
53-
expect(error).toBe(false);
54-
expect(message).toBe("Job has succedded.");
55-
worker.cleanupJob();
56-
})
57-
.catch((_) => {});
58-
});
48+
it("should initialize a python container with code in it", async () => {
49+
const worker = new JobWorker("python3", { code: "print('Hello World!')", functionName: "" });
50+
worker
51+
.initContainer()
52+
.then(({ error, message }) => {
53+
expect(error).toBe(false);
54+
expect(message).toBe("Job has succedded.");
55+
worker.cleanupJob();
56+
})
57+
.catch((_) => {});
58+
});
5959
});

src/types/worker.ts

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,68 +3,68 @@ export type fileFormat = "py" | "js";
33
export type Stdout = string;
44

55
export interface CodeContext {
6-
/**
7-
* raw string code to be excuted
8-
*/
9-
code: string;
6+
/**
7+
* raw string code to be excuted
8+
*/
9+
code: string;
1010

11-
/**
12-
* A method name in class to be executed
13-
*/
14-
functionName: string;
11+
/**
12+
* A method name in class to be executed
13+
*/
14+
functionName: string;
1515
}
1616

1717
interface BaseError {
18-
/**
19-
* Indicates an error during the process of spinning up the container
20-
*/
21-
error: boolean;
18+
/**
19+
* Indicates an error during the process of spinning up the container
20+
*/
21+
error: boolean;
2222

23-
/**
24-
* An error message in case the job fails
25-
*/
26-
errorMessage?: string;
23+
/**
24+
* An error message in case the job fails
25+
*/
26+
errorMessage?: string;
2727
}
2828

2929
export interface ContainerInitialization extends BaseError {
30-
/**
31-
* The ID of the newly created container
32-
*/
33-
containerID: string;
30+
/**
31+
* The ID of the newly created container
32+
*/
33+
containerID: string;
3434
}
3535

3636
export interface WriteFileStatus {
37-
/**
38-
* Newly created temp file that contain the context if exists
39-
*/
40-
filePath: string;
37+
/**
38+
* Newly created temp file that contain the context if exists
39+
*/
40+
filePath: string;
4141

42-
/**
43-
* The file format of the created file
44-
*/
45-
fileFormat: string;
42+
/**
43+
* The file format of the created file
44+
*/
45+
fileFormat: string;
4646
}
4747

4848
export interface JobStatus extends BaseError {
49-
/**
50-
* A brief message that describes that job status
51-
*/
52-
message: string;
49+
/**
50+
* A brief message that describes that job status
51+
*/
52+
message: string;
5353

54-
/**
55-
* indicates if the job is retryable
56-
*/
57-
retryable: boolean;
54+
/**
55+
* indicates if the job is retryable
56+
*/
57+
retryable: boolean;
5858

59-
/**
60-
* Newly created temp file that contain the context if exists
61-
*/
62-
filePath?: string;
59+
/**
60+
* Newly created temp file that contain the context if exists
61+
*/
62+
filePath?: string;
6363
}
6464

6565
export interface ExecuteContainer extends BaseError {
66-
/**
67-
* stdout from the container as a result of running the code
68-
*/
69-
codeOutput?: Stdout;
66+
/**
67+
* stdout from the container as a result of running the code
68+
*/
69+
codeOutput?: Stdout;
7070
}

0 commit comments

Comments
 (0)