@@ -41,16 +41,37 @@ describe('compose', function () {
4141 ( async ( ) => {
4242 var report = await compose . up ( ) ;
4343 expect ( report . services ) . to . be . ok ;
44- await new Promise ( r => setTimeout ( r , 2000 ) ) ;
45- let listContainers = await docker . listContainers ( { 'all' : true } ) ;
46- for ( var containerInfo of listContainers ) {
47- if ( containerInfo . Names [ 0 ] . includes ( "dockerodec_wordpress" ) ) {
48- let container = docker . getContainer ( containerInfo . Id ) ;
49- if ( containerInfo . State == 'running' )
50- await container . stop ( ) ;
51- await container . remove ( ) ;
52- }
53- }
44+ done ( ) ;
45+ } ) ( ) ;
46+ } ) ;
47+ afterEach ( 'clean up' , function ( done ) {
48+ this . timeout ( 60000 ) ;
49+ ( async ( ) => {
50+ await compose . down ( { volumes : true } ) ;
51+ done ( ) ;
52+ } ) ( ) ;
53+ } ) ;
54+ } ) ;
55+
56+ describe ( '#down' , function ( ) {
57+ beforeEach ( 'bring up' , function ( done ) {
58+ this . timeout ( 20000 ) ;
59+ ( async ( ) => {
60+ await compose . up ( ) ;
61+ done ( ) ;
62+ } ) ( ) ;
63+ } ) ;
64+ it ( "should do compose down" , function ( done ) {
65+ this . timeout ( 60000 ) ;
66+ ( async ( ) => {
67+ await compose . down ( { volumes : true } ) ;
68+ let listContainers = await docker . listContainers ( { 'all' : true , 'filters' : { "label" :[ `com.docker.compose.project=${ compose . projectName } ` ] } } ) ;
69+ expect ( listContainers ) . to . be . empty
70+ let listVolumes = await docker . listVolumes ( { 'filters' : { "label" :[ `com.docker.compose.project=${ compose . projectName } ` ] } } )
71+ expect ( listVolumes . Volumes ) . to . be . empty
72+ expect ( listVolumes . Warnings ) . to . be . null
73+ let listNetworks = await docker . listNetworks ( { 'filters' : { "label" :[ `com.docker.compose.project=${ compose . projectName } ` ] } } )
74+ expect ( listNetworks ) . to . be . empty
5475 done ( ) ;
5576 } ) ( ) ;
5677 } ) ;
@@ -62,16 +83,37 @@ describe('compose', function () {
6283 ( async ( ) => {
6384 var report = await compose_complex . up ( ) ;
6485 expect ( report . services ) . to . be . ok ;
65- await new Promise ( r => setTimeout ( r , 5000 ) ) ;
66- let listContainers = await docker . listContainers ( { 'all' : true } ) ;
67- for ( var containerInfo of listContainers ) {
68- if ( containerInfo . Names [ 0 ] . includes ( "dockerodec_complex" ) ) {
69- let container = docker . getContainer ( containerInfo . Id ) ;
70- if ( containerInfo . State == 'running' )
71- await container . stop ( ) ;
72- await container . remove ( ) ;
73- }
74- }
86+ done ( ) ;
87+ } ) ( ) ;
88+ } ) ;
89+ afterEach ( 'clean up' , function ( done ) {
90+ this . timeout ( 60000 ) ;
91+ ( async ( ) => {
92+ await compose_complex . down ( { volumes : true } ) ;
93+ done ( ) ;
94+ } ) ( ) ;
95+ } ) ;
96+ } ) ;
97+
98+ describe ( '#down_complex' , function ( ) {
99+ beforeEach ( 'bring up' , function ( done ) {
100+ this . timeout ( 300000 ) ;
101+ ( async ( ) => {
102+ await compose_complex . up ( ) ;
103+ done ( ) ;
104+ } ) ( ) ;
105+ } ) ;
106+ it ( "should do compose down complex example with extends and build" , function ( done ) {
107+ this . timeout ( 60000 ) ;
108+ ( async ( ) => {
109+ await compose_complex . down ( { volumes : true } ) ;
110+ let listContainers = await docker . listContainers ( { 'all' : true , 'filters' : { "label" :[ `com.docker.compose.project=${ compose . projectName } ` ] } } ) ;
111+ expect ( listContainers ) . to . be . empty
112+ let listVolumes = await docker . listVolumes ( { 'filters' : { "label" :[ `com.docker.compose.project=${ compose . projectName } ` ] } } )
113+ expect ( listVolumes . Volumes ) . to . be . empty
114+ expect ( listVolumes . Warnings ) . to . be . null
115+ let listNetworks = await docker . listNetworks ( { 'filters' : { "label" :[ `com.docker.compose.project=${ compose . projectName } ` ] } } )
116+ expect ( listNetworks ) . to . be . empty
75117 done ( ) ;
76118 } ) ( ) ;
77119 } ) ;
@@ -83,16 +125,6 @@ describe('compose', function () {
83125 ( async ( ) => {
84126 var report = await compose_build . up ( ) ;
85127 expect ( report . services ) . to . be . ok ;
86- await new Promise ( r => setTimeout ( r , 5000 ) ) ;
87- let listContainers = await docker . listContainers ( { 'all' : true } ) ;
88- for ( var containerInfo of listContainers ) {
89- if ( containerInfo . Names [ 0 ] . includes ( "dockerodec_build" ) ) {
90- let container = docker . getContainer ( containerInfo . Id ) ;
91- if ( containerInfo . State == 'running' )
92- await container . stop ( ) ;
93- await container . remove ( ) ;
94- }
95- }
96128 done ( ) ;
97129 } ) ( ) ;
98130 } ) ;
@@ -101,16 +133,37 @@ describe('compose', function () {
101133 ( async ( ) => {
102134 var report = await compose_build . up ( { 'verbose' : true } ) ;
103135 expect ( report . services ) . to . be . ok ;
104- await new Promise ( r => setTimeout ( r , 5000 ) ) ;
105- let listContainers = await docker . listContainers ( { 'all' : true } ) ;
106- for ( var containerInfo of listContainers ) {
107- if ( containerInfo . Names [ 0 ] . includes ( "dockerodec_build" ) ) {
108- let container = docker . getContainer ( containerInfo . Id ) ;
109- if ( containerInfo . State == 'running' )
110- await container . stop ( ) ;
111- await container . remove ( ) ;
112- }
113- }
136+ done ( ) ;
137+ } ) ( ) ;
138+ } ) ;
139+ afterEach ( 'clean up' , function ( done ) {
140+ this . timeout ( 60000 ) ;
141+ ( async ( ) => {
142+ await compose_build . down ( { volumes : true } ) ;
143+ done ( ) ;
144+ } ) ( ) ;
145+ } ) ;
146+ } ) ;
147+
148+ describe ( '#down_build' , function ( ) {
149+ beforeEach ( 'bring up' , function ( done ) {
150+ this . timeout ( 300000 ) ;
151+ ( async ( ) => {
152+ await compose_build . up ( ) ;
153+ done ( ) ;
154+ } ) ( ) ;
155+ } ) ;
156+ it ( "should do compose down example with build" , function ( done ) {
157+ this . timeout ( 60000 ) ;
158+ ( async ( ) => {
159+ await compose_build . down ( { volumes : true } ) ;
160+ let listContainers = await docker . listContainers ( { 'all' : true , 'filters' : { "label" :[ `com.docker.compose.project=${ compose . projectName } ` ] } } ) ;
161+ expect ( listContainers ) . to . be . empty
162+ let listVolumes = await docker . listVolumes ( { 'filters' : { "label" :[ `com.docker.compose.project=${ compose . projectName } ` ] } } )
163+ expect ( listVolumes . Volumes ) . to . be . empty
164+ expect ( listVolumes . Warnings ) . to . be . null
165+ let listNetworks = await docker . listNetworks ( { 'filters' : { "label" :[ `com.docker.compose.project=${ compose . projectName } ` ] } } )
166+ expect ( listNetworks ) . to . be . empty
114167 done ( ) ;
115168 } ) ( ) ;
116169 } ) ;
0 commit comments