From 49e7cc010beb03a43de1d05c2f4fc681618f88ce Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Thu, 16 Jun 2016 04:18:10 +0200 Subject: [PATCH] add tests with in docker --- Dockerfile | 8 +++++--- dist/dockersock.classes.dockersock.js | 10 +++++---- docker-compose.yml | 4 ---- package.json | 5 ++++- test/test.js | 17 +++++++++++++++- test/test.ts | 15 ++++++++++++++ ts/dockersock.classes.dockersock.ts | 29 ++++++++++++++------------- 7 files changed, 61 insertions(+), 27 deletions(-) diff --git a/Dockerfile b/Dockerfile index 70ce6dd..0513f4f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,6 @@ -FROM hosttoday/ht-docker-node:lts -COPY ./node_modules /app-node/node_modules -COPY ./dist /app-node/dist +FROM hosttoday/ht-docker-node:npmts +RUN mkdir app-node +COPY ./ /app-node/ +WORKDIR /app-node +ENV CI true CMD ["npmts"] \ No newline at end of file diff --git a/dist/dockersock.classes.dockersock.js b/dist/dockersock.classes.dockersock.js index 57c29ff..a793083 100644 --- a/dist/dockersock.classes.dockersock.js +++ b/dist/dockersock.classes.dockersock.js @@ -15,6 +15,7 @@ var Dockersock = (function () { }; ; Dockersock.prototype.listContainersDetailed = function () { + var _this = this; var done = plugins.q.defer(); var detailedDataObject = []; this.listContainers() @@ -22,10 +23,11 @@ var Dockersock = (function () { var recursiveCounter = 0; var makeDetailed = function () { if (typeof dataArg[recursiveCounter] != "undefined") { - this.request.get("GET", "/containers/" + dataArg[recursiveCounter].Id) - .then(function (data) { + _this.request("GET", "/containers/" + dataArg[recursiveCounter].Id) + .then(function (dataArg2) { + detailedDataObject.push(dataArg2); recursiveCounter++; - detailedDataObject.push(data); + // recursive call makeDetailed(); }); } @@ -84,4 +86,4 @@ var Dockersock = (function () { }()); exports.Dockersock = Dockersock; -//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImRvY2tlcnNvY2suY2xhc3Nlcy5kb2NrZXJ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AgICBsZXQgcmVjdXJzaXZlQ291bnRlciA9IDA7XG4gICAgICAgICAgICAgICAgICAgIGxldCBtYWtlRGV0YWlsZWQgPSBmdW5jdGlvbigpe1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYodHlwZW9mIGRhdGFBcmdbcmVjdXJzaXZlQ291bnRlcl0gIT0gXCJ1bmRlZmluZWRcIil7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXF1ZXN0LmdldChcIkdFVFwiLFwiL2NvbnRhaW5lcnMvXCIgKyBkYXRhQXJnW3JlY3Vyc2l2ZUNvdW50ZXJdLklkKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAudGhlbigoZGF0YSkgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdXJzaXZlQ291bnRlcisrO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGV0YWlsZWREYXRhT2JqZWN0LnB1c2goZGF0YSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYWtlRGV0YWlsZWQoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmUucmVzb2x2ZShkZXRhaWxlZERhdGFPYmplY3QpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICBtYWtlRGV0YWlsZWQoKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICByZXR1cm4gZG9uZS5wcm9taXNlO1xuICAgIH07XG4gICAgbGlzdENvbnRhaW5lcnNSdW5uaW5nKCkge1xuICAgICAgICBsZXQgZG9uZSA9IHBsdWdpbnMucS5kZWZlcigpO1xuICAgICAgICByZXR1cm4gZG9uZS5wcm9taXNlO1xuICAgIH1cbiAgICBsaXN0Q29udGFpbmVyc1N0b3BwZWQoKSB7XG4gICAgICAgIGxldCBkb25lID0gcGx1Z2lucy5xLmRlZmVyKCk7XG4gICAgICAgIHJldHVybiBkb25lLnByb21pc2U7XG4gICAgfVxuICAgIGxpc3RJbWFnZXMoKSB7XG4gICAgICAgIGxldCBkb25lID0gcGx1Z2lucy5xLmRlZmVyKCk7XG4gICAgICAgIHJldHVybiBkb25lLnByb21pc2U7XG4gICAgfVxuICAgIGNsZWFuKCkge1xuICAgICAgICBsZXQgZG9uZSA9IHBsdWdpbnMucS5kZWZlcigpO1xuICAgICAgICByZXR1cm4gZG9uZS5wcm9taXNlO1xuICAgIH1cblxuICAgIHJlcXVlc3QobWV0aG9kQXJnOnN0cmluZyxyb3V0ZUFyZzpzdHJpbmcsZGF0YUFyZyA9IHt9KXtcbiAgICAgICAgbGV0IGRvbmUgPSBwbHVnaW5zLnEuZGVmZXIoKTtcbiAgICAgICAgbGV0IGpzb25Bcmc6c3RyaW5nID0gSlNPTi5zdHJpbmdpZnkoZGF0YUFyZyk7XG4gICAgICAgIGxldCBvcHRpb25zID0ge1xuICAgICAgICAgICAgbWV0aG9kOm1ldGhvZEFyZyxcbiAgICAgICAgICAgIHVybDp0aGlzLnNvY2tQYXRoICsgcm91dGVBcmcgKyBcIi9qc29uXCIsXG4gICAgICAgICAgICBoZWFkZXJzOntcbiAgICAgICAgICAgICAgICBcIkNvbnRlbnQtVHlwZVwiOlwiYXBwbGljYXRpb24vanNvblwiXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgYm9keTpqc29uQXJnXG4gICAgICAgIH07XG4gICAgICAgIHBsdWdpbnMucmVxdWVzdChvcHRpb25zLGZ1bmN0aW9uKGVyciwgcmVzLCBib2R5KXtcbiAgICAgICAgICAgIGlmICghZXJyICYmIHJlcy5zdGF0dXNDb2RlID09IDIwMCkge1xuICAgICAgICAgICAgICAgIHZhciByZXNwb25zZU9iaiA9IEpTT04ucGFyc2UoYm9keSk7XG4gICAgICAgICAgICAg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IoKTtcbiAgICAgICAgdGhpcy5yZXF1ZXN0KFwiR0VUXCIsXCIvY29udGFpbmVyc1wiKVxuICAgICAgICAgICAgLnRoZW4oZG9uZS5yZXNvbHZlKTtcbiAgICAgICAgcmV0dXJuIGRvbmUucHJvbWlzZTtcbiAgICB9O1xuICAgIGxpc3RDb250YWluZXJzRGV0YWlsZWQoKSB7XG4gICAgICAgIGxldCBkb25lID0gcGx1Z2lucy5xLmRlZmVyKCk7XG4gICAgICAgIGxldCBkZXRhaWxlZERhdGFPYmplY3QgPSBbXTtcbiAgICAgICAgdGhpcy5saXN0Q29udGFpbmVycygpXG4gICAgICAgICAgICAudGhlbigoZGF0YUFyZykgPT4ge1xuICAgICAgICAgICAgICAgIGxldCByZWN1cnNpdmVDb3VudGVyID0gMDtcbiAgICAgICAgICAgICAgICBsZXQgbWFrZURldGFpbGVkID0gKCkgPT4ge1xuICAgICAgICAgICAgICAgICAgICBpZih0eXBlb2YgZGF0YUFyZ1tyZWN1cnNpdmVDb3VudGVyXSAhPSBcInVuZGVmaW5lZFwiKXtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucmVxdWVzdChcIkdFVFwiLFwiL2NvbnRhaW5lcnMvXCIgKyBkYXRhQXJnW3JlY3Vyc2l2ZUNvdW50ZXJdLklkKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC50aGVuKChkYXRhQXJnMikgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXRhaWxlZERhdGFPYmplY3QucHVzaChkYXRhQXJnMik7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY3Vyc2l2ZUNvdW50ZXIrKztcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gcmVjdXJzaXZlIGNhbGxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFrZURldGFpbGVkKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBkb25lLnJlc29sdmUoZGV0YWlsZWREYXRhT2JqZWN0KTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgbWFrZURldGFpbGVkKCk7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgcmV0dXJuIGRvbmUucHJvbWlzZTtcbiAgICB9O1xuICAgIGxpc3RDb250YWluZXJzUnVubmluZygpIHtcbiAgICAgICAgbGV0IGRvbmUgPSBwbHVnaW5zLnEuZGVmZXIoKTtcbiAgICAgICAgcmV0dXJuIGRvbmUucHJvbWlzZTtcbiAgICB9XG4gICAgbGlzdENvbnRhaW5lcnNTdG9wcGVkKCkge1xuICAgICAgICBsZXQgZG9uZSA9IHBsdWdpbnMucS5kZWZlcigpO1xuICAgICAgICByZXR1cm4gZG9uZS5wcm9taXNlO1xuICAgIH1cbiAgICBsaXN0SW1hZ2VzKCkge1xuICAgICAgICBsZXQgZG9uZSA9IHBsdWdpbnMucS5kZWZlcigpO1xuICAgICAgICByZXR1cm4gZG9uZS5wcm9taXNlO1xuICAgIH1cbiAgICBjbGVhbigpIHtcbiAgICAgICAgbGV0IGRvbmUgPSBwbHVnaW5zLnEuZGVmZXIoKTtcbiAgICAgICAgcmV0dXJuIGRvbmUucHJvbWlzZTtcbiAgICB9XG5cbiAgICByZXF1ZXN0KG1ldGhvZEFyZzpzdHJpbmcscm91dGVBcmc6c3RyaW5nLGRhdGFBcmcgPSB7fSl7XG4gICAgICAgIGxldCBkb25lID0gcGx1Z2lucy5xLmRlZmVyKCk7XG4gICAgICAgIGxldCBqc29uQXJnOnN0cmluZyA9IEpTT04uc3RyaW5naWZ5KGRhdGFBcmcpO1xuICAgICAgICBsZXQgb3B0aW9ucyA9IHtcbiAgICAgICAgICAgIG1ldGhvZDptZXRob2RBcmcsXG4gICAgICAgICAgICB1cmw6dGhpcy5zb2NrUGF0aCArIHJvdXRlQXJnICsgXCIvanNvblwiLFxuICAgICAgICAgICAgaGVhZGVyczp7XG4gICAgICAgICAgICAgICAgXCJDb250ZW50LVR5cGVcIjpcImFwcGxpY2F0aW9uL2pzb25cIlxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGJvZHk6anNvbkFyZ1xuICAgICAgICB9O1xuICAgICAgICBwbHVnaW5zLnJlcXVlc3Qob3B0aW9ucywoZXJyLCByZXMsIGJvZHkpID0+IHtcbiAgICAgICAgICAgIGlmICghZXJyICYmIHJlcy5zdGF0dXNDb2RlID09IDIwMCkge1xuICAgICAgICAgICAgICAgIHZhciByZXNwb25zZU9iaiA9IEpTT04ucGFyc2UoYm9keSk7XG4gICAgICAgICAgICAgICAgZG9uZS5yZXNvbHZlKHJlc3BvbnNlT2JqKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgY29uc29sZS5sb2coZXJyKTtcbiAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhyZXMpO1xuICAgICAgICAgICAgICAgIGRvbmUucmVqZWN0KGVycik7XG4gICAgICAgICAgICB9O1xuICAgICAgICB9KTtcbiAgICAgICAgcmV0dXJuIGRvbmUucHJvbWlzZTtcbiAgICB9XG59Il19 diff --git a/docker-compose.yml b/docker-compose.yml index ab3eb8d..9b7c0c5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,11 +12,7 @@ nginx2: container_name: nginx2 npmts-test-container: image: "npmts-test-image" - ports: - - "80:80" - - "443:443" volumes: - "/var/run/docker.sock:/var/run/docker.sock" - env_file: "nogit/nogit.env" restart: always container_name: npmts-test-container \ No newline at end of file diff --git a/package.json b/package.json index f156647..e40cdcb 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,10 @@ "description": "easy communication with docker from node, TypeScript ready", "main": "dist/index.js", "scripts": { - "test": "npmts testindocker" + "test": "npmts --notest && npm run cleanup && npm run build && npm run startdocker", + "build": "docker build -t npmts-test-image .", + "startdocker":"docker run -v /var/run/docker.sock:/var/run/docker.sock --name npmts-test-container npmts-test-image", + "cleanup":"docker rm npmts-test-container && docker rmi npmts-test-image" }, "repository": { "type": "git", diff --git a/test/test.js b/test/test.js index edfad6d..f21c742 100644 --- a/test/test.js +++ b/test/test.js @@ -9,7 +9,22 @@ describe("dockersock", function () { testDockersock = new index_1.Dockersock(); testDockersock.should.be.instanceof(index_1.Dockersock); }); + it("should list containers", function (done) { + testDockersock.listContainers() + .then(function (dataArg) { + console.log(dataArg); + done(); + }); + }); + it("should list detailed containers", function (done) { + this.timeout(5000); + testDockersock.listContainersDetailed() + .then(function (dataArg) { + console.log(dataArg); + done(); + }); + }); }); }); -//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFDdEIsUUFBTyxRQUVQLENBQUMsQ0FGYztBQUVmLHNCQUF5QixlQUV6QixDQUFDLENBRnVDO0FBRXhDLFFBQVEsQ0FBQyxZQUFZLEVBQUM7SUFDbEIsUUFBUSxDQUFDLGVBQWUsRUFBQztRQUNyQixJQUFJLGNBQXlCLENBQUM7UUFDOUIsRUFBRSxDQUFDLHlDQUF5QyxFQUFDO1lBQ3pDLGNBQWMsR0FBRyxJQUFJLGtCQUFVLEVBQUUsQ0FBQztZQUNsQyxjQUFjLENBQUMsTUFBTSxDQUFDLEVBQUUsQ0FBQyxVQUFVLENBQUMsa0JBQVUsQ0FBQyxDQUFDO1FBQ3BELENBQUMsQ0FBQyxDQUFDO0lBQ1AsQ0FBQyxDQUFDLENBQUM7QUFDUCxDQUFDLENBQUMsQ0FBQyIsImZpbGUiOiJ0ZXN0LmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFwidHlwaW5ncy10ZXN0XCI7XG5pbXBvcnQgXCJzaG91bGRcIlxuXG5pbXBvcnQge0RvY2tlcnN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c2hvdWxkLmJlLmluc3RhbmNlb2YoRG9ja2Vyc29jayk7XG4gICAgICAgIH0pO1xuICAgICAgICBpdChcInNob3VsZCBsaXN0IGNvbnRhaW5lcnNcIixmdW5jdGlvbihkb25lKXtcbiAgICAgICAgICAgIHRlc3REb2NrZXJzb2NrLmxpc3RDb250YWluZXJzKClcbiAgICAgICAgICAgICAgICAudGhlbigoZGF0YUFyZyk9PntcbiAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2coZGF0YUFyZyk7XG4gICAgICAgICAgICAgICAgICAgIGRvbmUoKTtcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgfSk7XG4gICAgICAgIGl0KFwic2hvdWxkIGxpc3QgZGV0YWlsZWQgY29udGFpbmVyc1wiLGZ1bmN0aW9uKGRvbmUpe1xuICAgICAgICAgICAgdGhpcy50aW1lb3V0KDUwMDApO1xuICAgICAgICAgICAgdGVzdERvY2tlcnNvY2subGlzdENvbnRhaW5lcnNEZXRhaWxlZCgpXG4gICAgICAgICAgICAgICAgLnRoZW4oKGRhdGFBcmcpPT57XG4gICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKGRhdGFBcmcpO1xuICAgICAgICAgICAgICAgICAgICBkb25lKCk7XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgIH0pO1xuICAgIH0pO1xufSk7Il19 diff --git a/test/test.ts b/test/test.ts index 176c6c1..2efd9f9 100644 --- a/test/test.ts +++ b/test/test.ts @@ -10,5 +10,20 @@ describe("dockersock",function(){ testDockersock = new Dockersock(); testDockersock.should.be.instanceof(Dockersock); }); + it("should list containers",function(done){ + testDockersock.listContainers() + .then((dataArg)=>{ + console.log(dataArg); + done(); + }); + }); + it("should list detailed containers",function(done){ + this.timeout(5000); + testDockersock.listContainersDetailed() + .then((dataArg)=>{ + console.log(dataArg); + done(); + }); + }); }); }); \ No newline at end of file diff --git a/ts/dockersock.classes.dockersock.ts b/ts/dockersock.classes.dockersock.ts index 478f6a1..a13549d 100644 --- a/ts/dockersock.classes.dockersock.ts +++ b/ts/dockersock.classes.dockersock.ts @@ -20,19 +20,20 @@ export class Dockersock { this.listContainers() .then((dataArg) => { let recursiveCounter = 0; - let makeDetailed = function(){ - if(typeof dataArg[recursiveCounter] != "undefined"){ - this.request.get("GET","/containers/" + dataArg[recursiveCounter].Id) - .then((data) => { - recursiveCounter++; - detailedDataObject.push(data); - makeDetailed(); - }); - } else { - done.resolve(detailedDataObject); - } - }; - makeDetailed(); + let makeDetailed = () => { + if(typeof dataArg[recursiveCounter] != "undefined"){ + this.request("GET","/containers/" + dataArg[recursiveCounter].Id) + .then((dataArg2) => { + detailedDataObject.push(dataArg2); + recursiveCounter++; + // recursive call + makeDetailed(); + }); + } else { + done.resolve(detailedDataObject); + } + }; + makeDetailed(); }); return done.promise; }; @@ -64,7 +65,7 @@ export class Dockersock { }, body:jsonArg }; - plugins.request(options,function(err, res, body){ + plugins.request(options,(err, res, body) => { if (!err && res.statusCode == 200) { var responseObj = JSON.parse(body); done.resolve(responseObj);