mirror of
https://github.com/danbulant/docker-compose
synced 2026-06-24 17:31:53 +00:00
feat: single container pause and unpause added
This commit is contained in:
parent
91abbfe63a
commit
5921b51977
2 changed files with 39 additions and 0 deletions
16
src/index.ts
16
src/index.ts
|
|
@ -273,6 +273,20 @@ export const stopOne = function (
|
||||||
return execCompose('stop', [service], options)
|
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 (
|
export const kill = function (
|
||||||
options?: IDockerComposeOptions
|
options?: IDockerComposeOptions
|
||||||
): Promise<IDockerComposeResult> {
|
): Promise<IDockerComposeResult> {
|
||||||
|
|
@ -497,6 +511,8 @@ export default {
|
||||||
down,
|
down,
|
||||||
stop,
|
stop,
|
||||||
stopOne,
|
stopOne,
|
||||||
|
pauseOne,
|
||||||
|
unpauseOne,
|
||||||
kill,
|
kill,
|
||||||
rm,
|
rm,
|
||||||
exec,
|
exec,
|
||||||
|
|
|
||||||
|
|
@ -223,6 +223,29 @@ test('ensure only single container gets stopped', async (): Promise<void> => {
|
||||||
await compose.down({ cwd: path.join(__dirname), log: logOutput })
|
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> => {
|
test('ensure container gets started with --abort-on-container-exit option', async (): Promise<void> => {
|
||||||
const result = await compose.upAll({
|
const result = await compose.upAll({
|
||||||
cwd: path.join(__dirname),
|
cwd: path.join(__dirname),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue