npmci/test/test.js

91 lines
6.8 KiB
JavaScript
Raw Permalink Normal View History

2016-06-05 11:01:45 +00:00
"use strict";
require("typings-test");
require("should");
2016-07-18 14:56:53 +00:00
const path = require("path");
const beautylog = require("beautylog");
2016-06-05 11:01:45 +00:00
//set up environment
process.env.CI_BUILD_REPO = "https://yyyyyy:xxxxxxxx@gitlab.com/mygroup/myrepo.git";
2016-06-26 00:17:17 +00:00
process.env.NPMCI_SSHKEY_1 = "hostString|somePrivKey|##";
2016-06-05 12:55:08 +00:00
process.env.NPMTS_TEST = "true";
2016-07-18 14:56:53 +00:00
process.cwd = () => {
2016-06-05 11:01:45 +00:00
return path.join(__dirname, "assets/");
};
2016-07-18 14:56:53 +00:00
const NpmciBuildDocker = require("../dist/npmci.build.docker");
const NpmciPublish = require("../dist/npmci.publish");
const NpmciTest = require("../dist/npmci.test");
const NpmciSsh = require("../dist/npmci.ssh");
let dockerfile1;
let dockerfile2;
let sortableArray;
2016-06-05 11:01:45 +00:00
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) {
2016-06-05 11:50:45 +00:00
beautylog.success("final result");
2016-06-05 11:01:45 +00:00
console.log(sortedArrayArg);
done();
});
});
2016-06-05 12:55:08 +00:00
it("should correctly chain Dockerfile handling", function (done) {
NpmciBuildDocker.build()
2016-07-18 14:56:53 +00:00
.then(() => {
2016-06-05 12:55:08 +00:00
done();
});
});
2016-06-05 11:01:45 +00:00
});
2016-06-05 15:17:15 +00:00
describe(".publish.docker", function () {
it("should publish all built Dockerfiles", function (done) {
NpmciPublish.publish("docker")
2016-07-18 14:56:53 +00:00
.then(() => {
2016-06-05 15:17:15 +00:00
done();
});
;
});
});
2016-06-05 14:56:07 +00:00
describe(".test.npm", function () {
2016-06-07 02:31:25 +00:00
it("should source nvm using bash and install a specific node version, then test it", function (done) {
2016-06-05 14:56:07 +00:00
NpmciTest.test("legacy")
2016-07-18 14:56:53 +00:00
.then(() => {
2016-06-05 14:56:07 +00:00
return NpmciTest.test("lts");
})
2016-07-18 14:56:53 +00:00
.then(() => {
2016-06-05 14:56:07 +00:00
return NpmciTest.test("stable");
})
2016-07-18 14:56:53 +00:00
.then(() => {
2016-06-07 02:31:25 +00:00
done();
});
});
});
describe("test.docker", function () {
it("should test dockerfiles", function (done) {
NpmciTest.test("docker")
2016-07-18 14:56:53 +00:00
.then(() => {
2016-06-05 14:56:07 +00:00
done();
});
});
});
2016-06-26 00:17:17 +00:00
describe("npmci prepare ssh", function () {
it("should pick up SSH keys", function (done) {
NpmciSsh.ssh()
2016-07-18 14:56:53 +00:00
.then(() => {
2016-06-26 00:17:17 +00:00
done();
});
});
});
2016-06-05 11:01:45 +00:00
});
2016-07-18 14:56:53 +00:00
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFDdEIsUUFBTyxRQUFRLENBQUMsQ0FBQTtBQUNoQixNQUFPLElBQUksV0FBVyxNQUFNLENBQUMsQ0FBQztBQUM5QixNQUFZLFNBQVMsV0FBTSxXQUUzQixDQUFDLENBRnFDO0FBQ3RDLG9CQUFvQjtBQUNwQixPQUFPLENBQUM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