npmci/test/test.js
2016-06-26 02:17:17 +02:00

93 lines
12 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.NPMCI_SSHKEY_1 = "hostString|somePrivKey|##";
process.env.NPMTS_TEST = "true";
process.cwd = function () {
return path.join(__dirname, "assets/");
};
var NpmciBuildDocker = require("../dist/npmci.build.docker");
var NpmciPublish = require("../dist/npmci.publish");
var NpmciTest = require("../dist/npmci.test");
var NpmciSsh = require("../dist/npmci.ssh");
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, then test it", function (done) {
NpmciTest.test("legacy")
.then(function () {
return NpmciTest.test("lts");
})
.then(function () {
return NpmciTest.test("stable");
})
.then(function () {
done();
});
});
});
describe("test.docker", function () {
it("should test dockerfiles", function (done) {
NpmciTest.test("docker")
.then(function () {
done();
});
});
});
describe("npmci prepare ssh", function () {
it("should pick up SSH keys", function (done) {
NpmciSsh.ssh()
.then(function () {
done();
});
});
});
});
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFDdEIsUUFBTyxRQUFRLENBQUMsQ0FBQTtBQUNoQixJQUFPLElBQUksV0FBVyxNQUFNLENBQUMsQ0FBQztBQUM5QixJQUFZLFNBQVMsV0FBTSxXQUUzQixDQUFDLENBRnFDO0FBQ3RDLG9CQUFvQjtBQUNwQixPQUFPLENBQUMsR0FBRyxDQUFDLGFBQWEsR0FBRyx1REFBdUQsQ0FBQztBQUNwRixPQUFPLENBQUMsR0FBRyxDQUFDLGNBQWMsR0FBRywyQkFBMkIsQ0FBQTtBQUN4RCxPQUFPLENBQUMsR0FBRyxDQUFDLFVBQVUsR0FBRyxNQUFNLENBQUM7QUFDaEMsT0FBTyxDQUFDLEdBQUcsR0FBRztJQUNWLE1BQU0sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLFNBQVMsRUFBQyxTQUFTLENBQUMsQ0FBQztBQUMxQyxDQUFDLENBQUM7QUFJRixJQUFPLGdCQUFnQixXQUFXLDRCQUE0QixDQUFDLENBQUM7QUFDaEUsSUFBTyxZQUFZLFdBQVcsdUJBQXVCLENBQUMsQ0FBQztBQUN2RCxJQUFPLFNBQVMsV0FBVyxvQkFBb0IsQ0FBQyxDQUFDO0FBQ2pELElBQU8sUUFBUSxXQUFXLG1CQUFtQixDQUFDLENBQUE7QUFHOUMsSUFBSSxXQUF1QyxDQUFDO0FBQzVDLElBQUksV0FBdUMsQ0FBQztBQUM1QyxJQUFJLGFBQTJDLENBQUM7QUFFaEQsUUFBUSxDQUFDLE9BQU8sRUFBQztJQUNiLFFBQVEsQ0FBQyxjQUFjLEVBQ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RG9ja2VyLkRvY2tlcmZpbGVbXSl7XG4gICAgICAgICAgICAgICAgICAgIGJlYXV0eWxvZy5zdWNjZXNzKFwiZmluYWwgcmVzdWx0XCIpO1xuICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhzb3J0ZWRBcnJheUFyZyk7XG4gICAgICAgICAgICAgICAgICAgIGRvbmUoKTtcbiAgICAgICAgICAgICAgICB9KVxuICAgICAgICB9KTtcbiAgICAgICAgaXQoXCJzaG91bGQgY29ycmVjdGx5IGNoYWluIERvY2tlcmZpbGUgaGFuZGxpbmdcIixmdW5jdGlvbihkb25lKXtcbiAgICAgICAgICAgIE5wbWNpQnVpbGREb2NrZXIuYnVpbGQoKVxuICAgICAgICAgICAgICAgIC50aGVuKCgpPT57XG4gICAgICAgICAgICAgICAgICAgIGRvbmUoKTtcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgfSlcbiAgICB9KTtcbiAgICBkZXNjcmliZShcIi5wdWJsaXNoLmRvY2tlclwiLGZ1bmN0aW9uKCl7XG4gICAgICAgIGl0KFwic2hvdWxkIHB1Ymxpc2ggYWxsIGJ1aWx0IERvY2tlcmZpbGVzXCIsZnVuY3Rpb24oZG9uZSl7XG4gICAgICAgICAgICBOcG1jaVB1Ymxpc2gucHVibGlzaChcImRvY2tlclwiKVxuICAgICAgICAgICAgICAgIC50aGVuKCgpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgZG9uZSgpO1xuICAgICAgICAgICAgICAgIH0pOztcbiAgICAgICAgfSk7XG4gICAgfSk7XG4gICAgZGVzY3JpYmUoXCIudGVzdC5ucG1cIixmdW5jdGlvbigpe1xuICAgICAgICBpdChcInNob3VsZCBzb3VyY2UgbnZtIHVzaW5nIGJhc2ggYW5kIGluc3RhbGwgYSBzcGVjaWZpYyBub2RlIHZlcnNpb24sIHRoZW4gdGVzdCBpdFwiLGZ1bmN0aW9uKGRvbmUpe1xuICAgICAgICAgICAgTnBtY2lUZXN0LnRlc3QoXCJsZWdhY3lcIilcbiAgICAgICAgICAgICAgICAudGhlbigoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBOcG1jaVRlc3QudGVzdChcImx0c1wiKTtcbiAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgICAgIC50aGVuKCgpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIE5wbWNpVGVzdC50ZXN0KFwic3RhYmxlXCIpO1xuICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAgICAgLnRoZW4oKCkgPT4ge1xuICAgICAgICAgICAgICAgICAgICBkb25lKCk7XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgIH0pXG4gICAgfSk7XG4gICAgZGVzY3JpYmUoXCJ0ZXN0LmRvY2tlclwiLGZ1bmN0aW9uKCl7XG4gICAgICAgIGl0KFwic2hvdWxkIHRlc3QgZG9ja2VyZmlsZXNcIixmdW5jdGlvbihkb25lKXtcbiAgICAgICAgICAgIE5wbWNpVGVzdC50ZXN0KFwiZG9ja2VyXCIpXG4gICAgICAgICAgICAgICAgLnRoZW4oKCkgPT4ge1xuICAgICAgICAgICAgICAgICAgICBkb25lKCk7XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgIH0pXG4gICAgfSk7XG4gICAgZGVzY3JpYmUoXCJucG1jaSBwcmVwYXJlIHNzaFwiLGZ1bmN0aW9uKCl7XG4gICAgICAgIGl0KFwic2hvdWxkIHBpY2sgdXAgU1NIIGtleXNcIixmdW5jdGlvbihkb25lKXtcbiAgICAgICAgICAgIE5wbWNpU3NoLnNzaCgpXG4gICAgICAgICAgICAgICAgLnRoZW4oKCkgPT4ge1xuICAgICAgICAgICAgICAgICAgICBkb25lKCk7XG4gICAgICAgICAgICAgICAgfSlcbiAgICAgICAgfSlcbiAgICB9KVxufSkiXX0=