2016-06-05 11:01:45 +00:00
|
|
|
import "typings-test";
|
|
|
|
import "should";
|
|
|
|
import path = require("path");
|
2016-06-05 11:50:45 +00:00
|
|
|
import * as beautylog from "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-05 12:55:08 +00:00
|
|
|
process.env.NPMTS_TEST = "true";
|
2016-06-05 11:01:45 +00:00
|
|
|
process.cwd = () => {
|
|
|
|
return path.join(__dirname,"assets/");
|
|
|
|
};
|
|
|
|
|
|
|
|
//require NPMCI files
|
|
|
|
import NpmciBuildDocker = require("../dist/npmci.build.docker");
|
2016-06-05 15:17:15 +00:00
|
|
|
import NpmciPublish = require("../dist/npmci.publish");
|
2016-06-05 14:56:07 +00:00
|
|
|
import NpmciTest = require("../dist/npmci.test");
|
2016-06-05 11:01:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
let dockerfile1:NpmciBuildDocker.Dockerfile;
|
|
|
|
let dockerfile2:NpmciBuildDocker.Dockerfile;
|
|
|
|
let sortableArray:NpmciBuildDocker.Dockerfile[];
|
|
|
|
|
|
|
|
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:NpmciBuildDocker.Dockerfile[]){
|
|
|
|
readDockerfilesArrayArg[1].version.should.equal("sometag1");
|
|
|
|
sortableArray = readDockerfilesArrayArg
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
})
|
|
|
|
it("should sort an array of Dockerfiles",function(done){
|
|
|
|
NpmciBuildDocker.sortDockerfiles(sortableArray)
|
|
|
|
.then(function(sortedArrayArg:NpmciBuildDocker.Dockerfile[]){
|
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()
|
|
|
|
.then(()=>{
|
|
|
|
done();
|
|
|
|
});
|
2016-06-05 11:01:45 +00:00
|
|
|
})
|
2016-06-05 14:56:07 +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")
|
|
|
|
.then(() => {
|
|
|
|
done();
|
|
|
|
});;
|
|
|
|
});
|
|
|
|
});
|
2016-06-05 14:56:07 +00:00
|
|
|
describe(".test.npm",function(){
|
|
|
|
it("should source nvm using bash and install a specific node version",function(done){
|
|
|
|
NpmciTest.test("legacy")
|
|
|
|
.then(() => {
|
|
|
|
return NpmciTest.test("lts");
|
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
return NpmciTest.test("stable");
|
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
return NpmciTest.test("docker");
|
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
})
|
|
|
|
});
|
2016-06-05 11:01:45 +00:00
|
|
|
})
|