started with tests

This commit is contained in:
Philipp Kunz 2016-06-05 13:50:45 +02:00
parent ea01b87949
commit e3c1ac1897
6 changed files with 40 additions and 21 deletions

View File

@ -1,6 +1,6 @@
export declare let build: () => any;
export declare let readDockerfiles: () => any;
export declare let cleanTagsArrayFunction: (dockerfileArrayArg: Dockerfile[]) => string[];
export declare let cleanTagsArrayFunction: (dockerfileArrayArg: Dockerfile[], trackingArrayArg: Dockerfile[]) => string[];
export declare let sortDockerfiles: (sortableArrayArg: Dockerfile[]) => any;
export declare let buildDockerfiles: () => any;
export declare class Dockerfile {

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
FROM myrepo/mygroup:sometag2
FROM mygroup/myrepo:sometag2
RUN apt-get update

View File

@ -2,6 +2,7 @@
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.cwd = function () {
@ -31,6 +32,7 @@ describe("NPMCI", function () {
it("should sort an array of Dockerfiles", function (done) {
NpmciBuildDocker.sortDockerfiles(sortableArray)
.then(function (sortedArrayArg) {
beautylog.success("final result");
console.log(sortedArrayArg);
done();
});
@ -38,4 +40,4 @@ describe("NPMCI", function () {
});
});
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFDdEIsUUFBTyxRQUFRLENBQUMsQ0FBQTtBQUNoQixJQUFPLElBQUksV0FBVyxNQUFNLENBQUMsQ0FBQztBQUM5QixvQkFBb0I7QUFDcEIsT0FBTyxDQUFDLEdBQUcsQ0FBQyxhQUFhLEdBQUcsdURBQXVELENBQUM7QUFDcEYsT0FBTyxDQUFDLEdBQUcsR0FBRztJQUNWLE1BQU0sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUF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YWwoXCJzb21ldGFnMVwiKTtcbiAgICAgICAgICAgICAgICAgICAgc29ydGFibGVBcnJheSA9IHJlYWREb2NrZXJmaWxlc0FycmF5QXJnXG4gICAgICAgICAgICAgICAgICAgIGRvbmUoKTtcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgfSlcbiAgICAgICAgaXQoXCJzaG91bGQgc29ydCBhbiBhcnJheSBvZiBEb2NrZXJmaWxlc1wiLGZ1bmN0aW9uKGRvbmUpe1xuICAgICAgICAgICAgTnBtY2lCdWlsZERvY2tlci5zb3J0RG9ja2VyZmlsZXMoc29ydGFibGVBcnJheSlcbiAgICAgICAgICAgICAgICAudGhlbihmdW5jdGlvbihzb3J0ZWRBcnJheUFyZzpOcG1jaUJ1aWxkRG9ja2VyLkRvY2tlcmZpbGVbXSl7XG4gICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKHNvcnRlZEFycmF5QXJnKTtcbiAgICAgICAgICAgICAgICAgICAgZG9uZSgpO1xuICAgICAgICAgICAgICAgIH0pXG4gICAgICAgIH0pXG4gICAgfSlcbn0pIl19
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFDdEIsUUFBTyxRQUFRLENBQUMsQ0FBQTtBQUNoQixJQUFPLElBQUksV0FBVyxNQUFNLENBQUMsQ0FBQztBQUM5QixJQUFZLFNBQVMsV0FBTSxXQUUzQixDQUFDLENBRnFDO0FBQ3RDLG9CQUFvQjtBQUNwQixPQUFPLENBQUMsR0FBRyxDQUFDLGFBQWEsR0FBRyx1REFBdUQsQ0FBQztBQUNwRixPQUFPLENBQUMsR0FBRyxHQUFHO0lBQ1YsTUFBTSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsU0FBUyxFQUFDLFNBQVMsQ0FBQyxDQUFDO0FBQzF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ja2VyZmlsZXNBcnJheUFyZ1sxXS52ZXJzaW9uLnNob3VsZC5lcXVhbChcInNvbWV0YWcxXCIpO1xuICAgICAgICAgICAgICAgICAgICBzb3J0YWJsZUFycmF5ID0gcmVhZERvY2tlcmZpbGVzQXJyYXlBcmdcbiAgICAgICAgICAgICAgICAgICAgZG9uZSgpO1xuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICB9KVxuICAgICAgICBpdChcInNob3VsZCBzb3J0IGFuIGFycmF5IG9mIERvY2tlcmZpbGVzXCIsZnVuY3Rpb24oZG9uZSl7XG4gICAgICAgICAgICBOcG1jaUJ1aWxkRG9ja2VyLnNvcnREb2NrZXJmaWxlcyhzb3J0YWJsZUFycmF5KVxuICAgICAgICAgICAgICAgIC50aGVuKGZ1bmN0aW9uKHNvcnRlZEFycmF5QXJnOk5wbWNpQnVpbGREb2NrZXIuRG9ja2VyZmlsZVtdKXtcbiAgICAgICAgICAgICAgICAgICAgYmVhdXR5bG9nLnN1Y2Nlc3MoXCJmaW5hbCByZXN1bHRcIik7XG4gICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKHNvcnRlZEFycmF5QXJnKTtcbiAgICAgICAgICAgICAgICAgICAgZG9uZSgpO1xuICAgICAgICAgICAgICAgIH0pXG4gICAgICAgIH0pXG4gICAgfSlcbn0pIl19

View File

@ -1,6 +1,7 @@
import "typings-test";
import "should";
import path = require("path");
import * as beautylog from "beautylog"
//set up environment
process.env.CI_BUILD_REPO = "https://yyyyyy:xxxxxxxx@gitlab.com/mygroup/myrepo.git";
process.cwd = () => {
@ -34,6 +35,7 @@ describe("NPMCI",function(){
it("should sort an array of Dockerfiles",function(done){
NpmciBuildDocker.sortDockerfiles(sortableArray)
.then(function(sortedArrayArg:NpmciBuildDocker.Dockerfile[]){
beautylog.success("final result");
console.log(sortedArrayArg);
done();
})

View File

@ -1,7 +1,6 @@
import * as plugins from "./npmci.plugins"
import * as NpmciEnv from "./npmci.env";
export let build = function(){
let done = plugins.q.defer();
@ -25,10 +24,12 @@ export let readDockerfiles = function(){
return done.promise;
}
export let cleanTagsArrayFunction = function(dockerfileArrayArg:Dockerfile[]):string[]{
export let cleanTagsArrayFunction = function(dockerfileArrayArg:Dockerfile[],trackingArrayArg:Dockerfile[]):string[]{
let cleanTagsArray:string[] = [];
dockerfileArrayArg.forEach(function(dockerfileArg){
if(trackingArrayArg.indexOf(dockerfileArg) == -1){
cleanTagsArray.push(dockerfileArg.cleanTag);
}
});
return cleanTagsArray;
}
@ -36,20 +37,26 @@ export let cleanTagsArrayFunction = function(dockerfileArrayArg:Dockerfile[]):st
export let sortDockerfiles = function(sortableArrayArg:Dockerfile[]){
let done = plugins.q.defer();
let sortedArray:Dockerfile[] = [];
let trackingArray:Dockerfile[] = [];
let sorterFunctionCounter:number = 0;
console.log(sortableArrayArg);
console.log(sortedArray);
let sorterFunction = function(){
plugins.beautylog.log("++++++++++++++++++++++++++++++++++++++++++++++");
console.log(sorterFunctionCounter);
let cleanTags = cleanTagsArrayFunction(sortableArrayArg);
sortableArrayArg.forEach((dockerfileArg)=>{
if(cleanTags.indexOf(dockerfileArg.baseImage) == -1){
let dockerfileArgIndex = sortableArrayArg.indexOf(dockerfileArg);
sortableArrayArg.splice(dockerfileArgIndex,1);
console.log(dockerfileArg);
let cleanTags = cleanTagsArrayFunction(sortableArrayArg,trackingArray);
console.log(cleanTags);
if(cleanTags.indexOf(dockerfileArg.baseImage) == -1 && trackingArray.indexOf(dockerfileArg) == -1){
sortedArray.push(dockerfileArg);
trackingArray.push(dockerfileArg);
}
});
if(sortableArrayArg.length == 0){
plugins.beautylog.info(sortedArray.length.toString());
if(sortableArrayArg.length == sortedArray.length){
done.resolve(sortedArray);
} else if (sorterFunctionCounter < 100) {
} else if (sorterFunctionCounter < 10) {
sorterFunctionCounter++;
sorterFunction();
};