From 7f7531febae6986a6e9441385380cc7e27d91475 Mon Sep 17 00:00:00 2001 From: Volodymyr Kolesnykov Date: Tue, 4 Jun 2024 15:55:55 +0300 Subject: [PATCH] test: add tests for `vip dev-env stop --all` --- __tests__/devenv-e2e/004-stop.spec.js | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/__tests__/devenv-e2e/004-stop.spec.js b/__tests__/devenv-e2e/004-stop.spec.js index 104362d368..efcd25b2dc 100644 --- a/__tests__/devenv-e2e/004-stop.spec.js +++ b/__tests__/devenv-e2e/004-stop.spec.js @@ -73,7 +73,7 @@ describe( 'vip dev-env stop', () => { true ); expect( result.rc ).toBe( 0 ); - expect( result.stdout ).toContain( 'environment stopped' ); + expect( result.stdout ).toContain( `environment "${ slug }" stopped` ); const containersAfterStop = await getContainersForProject( docker, slug ); expect( containersAfterStop ).toHaveLength( 0 ); @@ -91,11 +91,33 @@ describe( 'vip dev-env stop', () => { true ); expect( result.rc ).toBe( 0 ); - expect( result.stdout ).toContain( 'environment stopped' ); + expect( result.stdout ).toContain( `environment "${ slug }" stopped` ); const containersAfterStop = await getContainersForProject( docker, slug ); expect( containersAfterStop ).toHaveLength( 0 ); await destroyEnvironment( cliTest, slug, env ); } ); + + it( 'should be able to stop all environments', async () => { + const slug1 = getProjectSlug(); + const slug2 = getProjectSlug(); + expect( await checkEnvExists( slug1 ) ).toBe( false ); + expect( await checkEnvExists( slug2 ) ).toBe( false ); + + await createAndStartEnvironment( cliTest, slug1, env ); + await createAndStartEnvironment( cliTest, slug2, env ); + + const result = await cliTest.spawn( + [ process.argv[ 0 ], vipDevEnvStop, '--all' ], + { env }, + true + ); + expect( result.rc ).toBe( 0 ); + expect( result.stdout ).toContain( `environment "${ slug1 }" stopped` ); + expect( result.stdout ).toContain( `environment "${ slug2 }" stopped` ); + + await destroyEnvironment( cliTest, slug1, env ); + await destroyEnvironment( cliTest, slug2, env ); + } ); } );