Skip to content

Commit

Permalink
Merge branch 'main' into fix-depends-on
Browse files Browse the repository at this point in the history
  • Loading branch information
apocas authored Feb 28, 2022
2 parents ff03c5f + 87fb986 commit 7fa75a8
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 40 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
name: Node.js CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

Expand All @@ -25,4 +27,5 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- run: npm test
133 changes: 93 additions & 40 deletions test/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,37 @@ describe('compose', function () {
(async () => {
var report = await compose.up();
expect(report.services).to.be.ok;
await new Promise(r => setTimeout(r, 2000));
let listContainers = await docker.listContainers({ 'all': true });
for (var containerInfo of listContainers) {
if (containerInfo.Names[0].includes("dockerodec_wordpress")) {
let container = docker.getContainer(containerInfo.Id);
if (containerInfo.State == 'running')
await container.stop();
await container.remove();
}
}
done();
})();
});
afterEach('clean up', function (done) {
this.timeout(60000);
(async () => {
await compose.down({ volumes: true });
done();
})();
});
});

describe('#down', function () {
beforeEach('bring up', function (done) {
this.timeout(20000);
(async () => {
await compose.up();
done();
})();
});
it("should do compose down", function (done) {
this.timeout(60000);
(async () => {
await compose.down({volumes: true});
let listContainers = await docker.listContainers({ 'all': true, 'filters': {"label":[`com.docker.compose.project=${compose.projectName}`]}});
expect(listContainers).to.be.empty
let listVolumes = await docker.listVolumes({ 'filters': {"label":[`com.docker.compose.project=${compose.projectName}`]}})
expect(listVolumes.Volumes).to.be.empty
expect(listVolumes.Warnings).to.be.null
let listNetworks = await docker.listNetworks({ 'filters': {"label":[`com.docker.compose.project=${compose.projectName}`]}})
expect(listNetworks).to.be.empty
done();
})();
});
Expand All @@ -62,16 +83,37 @@ describe('compose', function () {
(async () => {
var report = await compose_complex.up();
expect(report.services).to.be.ok;
await new Promise(r => setTimeout(r, 5000));
let listContainers = await docker.listContainers({ 'all': true });
for (var containerInfo of listContainers) {
if (containerInfo.Names[0].includes("dockerodec_complex")) {
let container = docker.getContainer(containerInfo.Id);
if (containerInfo.State == 'running')
await container.stop();
await container.remove();
}
}
done();
})();
});
afterEach('clean up', function (done) {
this.timeout(60000);
(async () => {
await compose_complex.down({ volumes: true });
done();
})();
});
});

describe('#down_complex', function () {
beforeEach('bring up', function (done) {
this.timeout(300000);
(async () => {
await compose_complex.up();
done();
})();
});
it("should do compose down complex example with extends and build", function (done) {
this.timeout(60000);
(async () => {
await compose_complex.down({volumes: true});
let listContainers = await docker.listContainers({ 'all': true, 'filters': {"label":[`com.docker.compose.project=${compose.projectName}`]}});
expect(listContainers).to.be.empty
let listVolumes = await docker.listVolumes({ 'filters': {"label":[`com.docker.compose.project=${compose.projectName}`]}})
expect(listVolumes.Volumes).to.be.empty
expect(listVolumes.Warnings).to.be.null
let listNetworks = await docker.listNetworks({ 'filters': {"label":[`com.docker.compose.project=${compose.projectName}`]}})
expect(listNetworks).to.be.empty
done();
})();
});
Expand All @@ -83,16 +125,6 @@ describe('compose', function () {
(async () => {
var report = await compose_build.up();
expect(report.services).to.be.ok;
await new Promise(r => setTimeout(r, 5000));
let listContainers = await docker.listContainers({ 'all': true });
for (var containerInfo of listContainers) {
if (containerInfo.Names[0].includes("dockerodec_build")) {
let container = docker.getContainer(containerInfo.Id);
if (containerInfo.State == 'running')
await container.stop();
await container.remove();
}
}
done();
})();
});
Expand All @@ -101,16 +133,37 @@ describe('compose', function () {
(async () => {
var report = await compose_build.up({ 'verbose': true });
expect(report.services).to.be.ok;
await new Promise(r => setTimeout(r, 5000));
let listContainers = await docker.listContainers({ 'all': true });
for (var containerInfo of listContainers) {
if (containerInfo.Names[0].includes("dockerodec_build")) {
let container = docker.getContainer(containerInfo.Id);
if (containerInfo.State == 'running')
await container.stop();
await container.remove();
}
}
done();
})();
});
afterEach('clean up', function (done) {
this.timeout(60000);
(async () => {
await compose_build.down({ volumes: true });
done();
})();
});
});

describe('#down_build', function () {
beforeEach('bring up', function (done) {
this.timeout(300000);
(async () => {
await compose_build.up();
done();
})();
});
it("should do compose down example with build", function (done) {
this.timeout(60000);
(async () => {
await compose_build.down({volumes: true});
let listContainers = await docker.listContainers({ 'all': true, 'filters': {"label":[`com.docker.compose.project=${compose.projectName}`]}});
expect(listContainers).to.be.empty
let listVolumes = await docker.listVolumes({ 'filters': {"label":[`com.docker.compose.project=${compose.projectName}`]}})
expect(listVolumes.Volumes).to.be.empty
expect(listVolumes.Warnings).to.be.null
let listNetworks = await docker.listNetworks({ 'filters': {"label":[`com.docker.compose.project=${compose.projectName}`]}})
expect(listNetworks).to.be.empty
done();
})();
});
Expand Down

0 comments on commit 7fa75a8

Please sign in to comment.