@@ -2,58 +2,58 @@ import { ContainerInitialization } from "../src/types/worker";
22import JobWorker from "../src/worker" ;
33
44describe ( "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} ) ;
0 commit comments