Merge pull request #90 from Steveb-p/add-pull

Add pullOne, pullMany and pullAll methods
This commit is contained in:
Alexander Zeitler 2019-08-30 14:12:44 +02:00 committed by GitHub
commit bdd539ce8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 65 additions and 0 deletions

View file

@ -172,6 +172,18 @@ export const buildOne = function (service: string, options?: IDockerComposeBuild
return execCompose('build', [ service ], options);
};
export const pullAll = function (options: IDockerComposeOptions = {}): Promise<IDockerComposeResult> {
return execCompose('pull', [], options);
};
export const pullMany = function (services: string[], options: IDockerComposeOptions = {}): Promise<IDockerComposeResult> {
return execCompose('pull', services, options);
};
export const pullOne = function (service: string, options?: IDockerComposeOptions): Promise<IDockerComposeResult> {
return execCompose('pull', [ service ], options);
};
export const config = function (options?: IDockerComposeOptions): Promise<IDockerComposeResult> {
return execCompose('config', [], options);
};

View file

@ -323,6 +323,59 @@ test('build all services', async (): Promise<void> => {
await removeImagesStartingWith('compose-test-build-image');
});
test('pull single service', async (): Promise<void> => {
const opts = {
cwd: path.join(__dirname),
log: logOutput,
config: 'docker-compose.yml'
};
await removeImagesStartingWith('nginx:1.16.0');
expect(await imageExists('nginx:1.16.0')).toBeFalsy();
await compose.pullOne('db', opts);
expect(await imageExists('nginx:1.16.0')).toBeTruthy();
});
test('pull multiple services', async (): Promise<void> => {
const opts = {
cwd: path.join(__dirname),
log: logOutput,
config: 'docker-compose.yml'
};
await removeImagesStartingWith('nginx:1.16.0');
await removeImagesStartingWith('alpine:3.7.3');
expect(await imageExists('nginx:1.16.0')).toBeFalsy();
expect(await imageExists('alpine:3.7.3')).toBeFalsy();
await compose.pullMany([ 'db', 'alpine' ], opts);
expect(await imageExists('nginx:1.16.0')).toBeTruthy();
expect(await imageExists('alpine:3.7.3')).toBeTruthy();
});
test('pull all services', async (): Promise<void> => {
const opts = {
cwd: path.join(__dirname),
log: logOutput,
config: 'docker-compose.yml'
};
await removeImagesStartingWith('nginx:1.16.0');
await removeImagesStartingWith('alpine:3.7.3');
expect(await imageExists('nginx:1.16.0')).toBeFalsy();
expect(await imageExists('alpine:3.7.3')).toBeFalsy();
await compose.pullAll(opts);
expect(await imageExists('nginx:1.16.0')).toBeTruthy();
expect(await imageExists('alpine:3.7.3')).toBeTruthy();
});
test('teardown', async (): Promise<void> => {
interface Container {
Names: string[];