79 lines
10 KiB
JavaScript
79 lines
10 KiB
JavaScript
"use strict";
|
|
require("typings-test");
|
|
require("should");
|
|
var path = require("path");
|
|
var beautylog = require("beautylog");
|
|
//set up environment
|
|
process.env.CI_BUILD_REPO = "https://yyyyyy:xxxxxxxx@gitlab.com/mygroup/myrepo.git";
|
|
process.env.NPMTS_TEST = "true";
|
|
process.cwd = function () {
|
|
return path.join(__dirname, "assets/");
|
|
};
|
|
//require NPMCI files
|
|
var NpmciBuildDocker = require("../dist/npmci.build.docker");
|
|
var NpmciPublish = require("../dist/npmci.publish");
|
|
var NpmciTest = require("../dist/npmci.test");
|
|
var dockerfile1;
|
|
var dockerfile2;
|
|
var sortableArray;
|
|
describe("NPMCI", function () {
|
|
describe("build.docker", function () {
|
|
it("should return valid Dockerfiles", function () {
|
|
dockerfile1 = new NpmciBuildDocker.Dockerfile({ filePath: "./Dockerfile", read: true });
|
|
dockerfile2 = new NpmciBuildDocker.Dockerfile({ filePath: "./Dockerfile_sometag1", read: true });
|
|
dockerfile1.version.should.equal("latest");
|
|
dockerfile2.version.should.equal("sometag1");
|
|
});
|
|
it("should read a directory of Dockerfiles", function (done) {
|
|
NpmciBuildDocker.readDockerfiles()
|
|
.then(function (readDockerfilesArrayArg) {
|
|
readDockerfilesArrayArg[1].version.should.equal("sometag1");
|
|
sortableArray = readDockerfilesArrayArg;
|
|
done();
|
|
});
|
|
});
|
|
it("should sort an array of Dockerfiles", function (done) {
|
|
NpmciBuildDocker.sortDockerfiles(sortableArray)
|
|
.then(function (sortedArrayArg) {
|
|
beautylog.success("final result");
|
|
console.log(sortedArrayArg);
|
|
done();
|
|
});
|
|
});
|
|
it("should correctly chain Dockerfile handling", function (done) {
|
|
NpmciBuildDocker.build()
|
|
.then(function () {
|
|
done();
|
|
});
|
|
});
|
|
});
|
|
describe(".publish.docker", function () {
|
|
it("should publish all built Dockerfiles", function (done) {
|
|
NpmciPublish.publish("docker")
|
|
.then(function () {
|
|
done();
|
|
});
|
|
;
|
|
});
|
|
});
|
|
describe(".test.npm", function () {
|
|
it("should source nvm using bash and install a specific node version", function (done) {
|
|
NpmciTest.test("legacy")
|
|
.then(function () {
|
|
return NpmciTest.test("lts");
|
|
})
|
|
.then(function () {
|
|
return NpmciTest.test("stable");
|
|
})
|
|
.then(function () {
|
|
return NpmciTest.test("docker");
|
|
})
|
|
.then(function () {
|
|
done();
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFDdEIsUUFBTyxRQUFRLENBQUMsQ0FBQTtBQUNoQixJQUFPLElBQUksV0FBVyxNQUFNLENBQUMsQ0FBQztBQUM5QixJQUFZLFNBQVMsV0FBTSxXQUUzQixDQUFDLENBRnFDO0FBQ3RDLG9CQUFvQjtBQUNwQixPQUFPLENBQUMsR0FBRyxDQUFDLGFBQWEsR0FBRyx1REFBdUQsQ0FBQztBQUNwRixPQUFPLENBQUMsR0FBRyxDQUFDLFVBQVUsR0FBRyxNQUFNLENBQUM7QUFDaEMsT0FBTyxDQUFDLEdBQUcsR0FBRztJQUNWLE1BQU0sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLFNBQVMsRUFBQyxTQUFTLENBQUMsQ0FBQztBQUMxQyxDQUFDLENBQUM7QUFFRixxQkFBcUI7QUFDckIsSUFBTyxnQkFBZ0IsV0FBVyw0QkFBNEIsQ0FBQyxDQUFDO0FBQ2hFLElBQU8sWUFBWSxXQUFXLHVCQUF1QixDQUFDLENBQUM7QUFDdkQsSUFBTyxTQUFTLFdBQVcsb0JBQW9CLENBQUMsQ0FBQztBQUdqRCxJQUFJLFdBQXVDLENBQUM7QUFDNUMsSUFBSSxXQUF1QyxDQUFDO0FBQzVDLElBQUksYUFBMkMsQ0FBQztBQUVoRCxRQUFR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dW5jdGlvbihyZWFkRG9ja2VyZmlsZXNBcnJheUFyZzpOcG1jaUJ1aWxkRG9ja2VyLkRvY2tlcmZpbGVbXSl7XHJcbiAgICAgICAgICAgICAgICAgICAgcmVhZERvY2tlcmZpbGVzQXJyYXlBcmdbMV0udmVyc2lvbi5zaG91bGQuZXF1YWwoXCJzb21ldGFnMVwiKTtcclxuICAgICAgICAgICAgICAgICAgICBzb3J0YWJsZUFycmF5ID0gcmVhZERvY2tlcmZpbGVzQXJyYXlBcmdcclxuICAgICAgICAgICAgICAgICAgICBkb25lKCk7XHJcbiAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICB9KVxyXG4gICAgICAgIGl0KFwic2hvdWxkIHNvcnQgYW4gYXJyYXkgb2YgRG9ja2VyZmlsZXNcIixmdW5jdGlvbihkb25lKXtcclxuICAgICAgICAgICAgTnBtY2lCdWlsZERvY2tlci5zb3J0RG9ja2VyZmlsZXMoc29ydGFibGVBcnJheSlcclxuICAgICAgICAgICAgICAgIC50aGVuKGZ1bmN0aW9uKHNvcnRlZEFycmF5QXJnOk5wbWNpQnVpbGREb2NrZXIuRG9ja2VyZmlsZVtdKXtcclxuICAgICAgICAgICAgICAgICAgICBiZWF1dHlsb2cuc3VjY2VzcyhcImZpbmFsIHJlc3VsdFwiKTtcclxuICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhzb3J0ZWRBcnJheUFyZyk7XHJcbiAgICAgICAgICAgICAgICAgICAgZG9uZSgpO1xyXG4gICAgICAgICAgICAgICAgfSlcclxuICAgICAgICB9KTtcclxuICAgICAgICBpdChcInNob3VsZCBjb3JyZWN0bHkgY2hhaW4gRG9ja2VyZmlsZSBoYW5kbGluZ1wiLGZ1bmN0aW9uKGRvbmUpe1xyXG4gICAgICAgICAgICBOcG1jaUJ1aWxkRG9ja2VyLmJ1aWxkKClcclxuICAgICAgICAgICAgICAgIC50aGVuKCgpPT57XHJcbiAgICAgICAgICAgICAgICAgICAgZG9uZSgpO1xyXG4gICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgfSlcclxuICAgIH0pO1xyXG4gICAgZGVzY3JpYmUoXCIucHVibGlzaC5kb2NrZXJcIixmdW5jdGlvbigpe1xyXG4gICAgICAgIGl0KFwic2hvdWxkIHB1Ymxpc2ggYWxsIGJ1aWx0IERvY2tlcmZpbGVzXCIsZnVuY3Rpb24oZG9uZSl7XHJcbiAgICAgICAgICAgIE5wbWNpUHVibGlzaC5wdWJsaXNoKFwiZG9ja2VyXCIpXHJcbiAgICAgICAgICAgICAgICAudGhlbigoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgZG9uZSgpO1xyXG4gICAgICAgICAgICAgICAgfSk7O1xyXG4gICAgICAgIH0pO1xyXG4gICAgfSk7XHJcbiAgICBkZXNjcmliZShcIi50ZXN0Lm5wbVwiLGZ1bmN0aW9uKCl7XHJcbiAgICAgICAgaXQoXCJzaG91bGQgc291cmNlIG52bSB1c2luZyBiYXNoIGFuZCBpbnN0YWxsIGEgc3BlY2lmaWMgbm9kZSB2ZXJzaW9uXCIsZnVuY3Rpb24oZG9uZSl7XHJcbiAgICAgICAgICAgIE5wbWNpVGVzdC50ZXN0KFwibGVnYWN5XCIpXHJcbiAgICAgICAgICAgICAgICAudGhlbigoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIE5wbWNpVGVzdC50ZXN0KFwibHRzXCIpO1xyXG4gICAgICAgICAgICAgICAgfSlcclxuICAgICAgICAgICAgICAgIC50aGVuKCgpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gTnBtY2lUZXN0LnRlc3QoXCJzdGFibGVcIik7XHJcbiAgICAgICAgICAgICAgICB9KVxyXG4gICAgICAgICAgICAgICAgLnRoZW4oKCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICByZXR1cm4gTnBtY2lUZXN0LnRlc3QoXCJkb2NrZXJcIik7XHJcbiAgICAgICAgICAgICAgICB9KVxyXG4gICAgICAgICAgICAgICAgLnRoZW4oKCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgIGRvbmUoKTtcclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgIH0pXHJcbiAgICB9KTtcclxufSkiXX0=
|