File tree Expand file tree Collapse file tree 6 files changed +29
-8
lines changed Expand file tree Collapse file tree 6 files changed +29
-8
lines changed Original file line number Diff line number Diff line change 22module . exports = {
33 preset : "ts-jest" ,
44 testEnvironment : "node" ,
5+ modulePaths : [ "<rootDir>/src/tests" ] ,
56 moduleNameMapper : {
67 "^@/(.*)$" : "<rootDir>/src/$1" ,
78 } ,
Original file line number Diff line number Diff line change 11{
22 "name" : " nerdctl" ,
3- "version" : " 0.0.7 " ,
3+ "version" : " 0.1.0 " ,
44 "main" : " dist/index.js" ,
55 "types" : " dist/index.d.ts" ,
66 "description" : " Node wrapper for nerdctl" ,
Original file line number Diff line number Diff line change 1+ import { ChildProcess } from "child_process" ;
12import { factory } from ".." ;
23
34describe ( "container" , ( ) => {
45 const engine = factory ( ) ;
56 const IMAGE = "hello-world" ;
67 const NAME = "hello" ;
78
8- test ( "rm" , async ( ) => {
9- await engine . run ( IMAGE , { name : NAME , detach : true } ) ;
10- const result = await engine . rm ( NAME , { force : true } ) ;
9+ test ( "run" , async ( ) => {
10+ const result = ( await engine . run ( IMAGE , {
11+ name : NAME ,
12+ detach : true ,
13+ } ) ) as ChildProcess ;
14+ expect ( result . exitCode ) . toBeNull ( ) ;
15+ } ) ;
1116
12- expect ( result . code ) . toEqual ( 0 ) ;
17+ afterAll ( ( ) => {
18+ ( async ( ) => {
19+ await engine . rm ( IMAGE ) ;
20+ } ) ( ) ;
1321 } ) ;
1422} ) ;
Original file line number Diff line number Diff line change @@ -45,6 +45,11 @@ export default abstract class BaseBackend {
4545 if ( flags ) {
4646 for ( const [ key , value ] of Object . entries ( flags ) ) {
4747 const flag = `--${ paramCase ( key ) } ` ;
48+ if ( Array . isArray ( value ) ) {
49+ value . forEach ( ( val ) => {
50+ flagParams . push ( `${ flag } ${ val } ` ) ;
51+ } ) ;
52+ }
4853 if ( typeof value === "boolean" ) {
4954 flagParams . push ( flag ) ;
5055 }
Original file line number Diff line number Diff line change @@ -84,9 +84,16 @@ export default class LimaBackend extends BaseBackend {
8484
8585 return new Promise ( ( resolve , reject ) => {
8686 if ( ! ! child . exitCode ) reject ( null ) ;
87+
88+ const images : ImageResult [ ] = [ ] ;
89+
8790 child . stdout ! . on ( "data" , ( data ) => {
88- if ( ! data ) reject ( null ) ;
89- resolve ( JSON . parse ( data ) ) ;
91+ if ( ! data ) return ;
92+ images . push ( JSON . parse ( data ) ) ;
93+ } ) ;
94+
95+ child . stdout ! . on ( "close" , ( ) => {
96+ resolve ( images ) ;
9097 } ) ;
9198 } ) ;
9299 }
Original file line number Diff line number Diff line change 1414 }
1515 },
1616 "include" : [" src" ],
17- "exclude" : [" node_modules" ]
17+ "exclude" : [" node_modules" , " docs " , " src/tests " ]
1818}
You can’t perform that action at this time.
0 commit comments