feat: single container pause and unpause added

This commit is contained in:
Westlad 2021-07-19 15:18:14 +01:00 committed by Alexander Zeitler
parent 91abbfe63a
commit 5921b51977
2 changed files with 39 additions and 0 deletions

View file

@ -273,6 +273,20 @@ export const stopOne = function (
return execCompose('stop', [service], options)
}
export const pauseOne = function (
service: string,
options?: IDockerComposeOptions
): Promise<IDockerComposeResult> {
return execCompose('pause', [service], options)
}
export const unpauseOne = function (
service: string,
options?: IDockerComposeOptions
): Promise<IDockerComposeResult> {
return execCompose('unpause', [service], options)
}
export const kill = function (
options?: IDockerComposeOptions
): Promise<IDockerComposeResult> {
@ -497,6 +511,8 @@ export default {
down,
stop,
stopOne,
pauseOne,
unpauseOne,
kill,
rm,
exec,

View file

@ -223,6 +223,29 @@ test('ensure only single container gets stopped', async (): Promise<void> => {
await compose.down({ cwd: path.join(__dirname), log: logOutput })
})
test('ensure only single container gets paused then resumed', async (): Promise<void> => {
const opts = { cwd: path.join(__dirname), log: logOutput }
await compose.upAll(opts)
expect(await isContainerRunning('/compose_test_web')).toBeTruthy()
expect(await isContainerRunning('/compose_test_proxy')).toBeTruthy()
await compose.pauseOne('proxy', opts)
expect(await isContainerRunning('/compose_test_web')).toBeTruthy()
expect(await isContainerRunning('/compose_test_proxy')).toBeTruthy()
try {
await compose.exec('proxy', 'cat /etc/os-release', opts)
fail('Container was not paused')
} catch(err) {
expect(err.err).toContain('is paused')
}
await compose.unpauseOne('proxy', opts)
expect(await isContainerRunning('/compose_test_web')).toBeTruthy()
expect(await isContainerRunning('/compose_test_proxy')).toBeTruthy()
const std = await compose.exec('proxy', 'cat /etc/os-release', opts)
expect(std.out).toContain('Alpine Linux')
await compose.down(opts)
})
test('ensure container gets started with --abort-on-container-exit option', async (): Promise<void> => {
const result = await compose.upAll({
cwd: path.join(__dirname),