Skip to content

Commit

Permalink
test: add tests for vip dev-env stop --all
Browse files Browse the repository at this point in the history
  • Loading branch information
sjinks committed Jun 4, 2024
1 parent 2a28db3 commit de22e2c
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions __tests__/devenv-e2e/004-stop.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe( 'vip dev-env stop', () => {
env,
} );
expect( result.rc ).toBeGreaterThan( 0 );
expect( result.stderr ).toContain( "Error: Environment doesn't exist." );
expect( result.stderr ).toContain( 'Error: Environment not found.' );

return expect( checkEnvExists( slug ) ).resolves.toBe( false );
} );
Expand All @@ -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 );
Expand All @@ -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 );
} );
} );

0 comments on commit de22e2c

Please sign in to comment.