All files compile-required-images.js

100% Statements 16/16
100% Branches 6/6
100% Functions 5/5
100% Lines 15/15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29    1x         6x 6x 8x 1x   7x 10x 10x 10x 7x 3x 1x 1x     6x         1x  
import stringify from './stringify';
 
module.exports = function({
    isSupported,
    manifestContainerBuilds,
    compareBuilds,
}) {
    return function compileRequiredImages(projectId, manifests) {
        return manifests.reduce((accum, manifest) => {
            if (!isSupported(manifest)) {
                return accum;
            }
            manifestContainerBuilds(projectId, manifest).forEach(containerBuild => {
                const {image, build} = containerBuild;
                const exists = accum.filter(c => c.image.fullname === image.fullname)[0];
                if (!exists) {
                    accum.push(containerBuild)
                } else if (!compareBuilds(exists.build, build)) {
                    console.log(stringify(exists.build), stringify(build));
                    throw REPEAT_ERROR;
                }
            });
            return accum;
        }, []);
    }
}
 
export const REPEAT_ERROR = 'Repeat container builds must have identical builds';