npmci/test/test.ts

101 lines
3.2 KiB
TypeScript
Raw Permalink Normal View History

2016-11-15 00:07:55 +01:00
import 'typings-test'
import * as should from 'should'
2016-11-24 23:21:40 +01:00
import * as path from 'path'
2016-11-15 00:07:55 +01:00
// 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'
2016-06-05 13:01:45 +02:00
process.cwd = () => {
2016-11-15 00:07:55 +01:00
return path.join(__dirname,'assets/')
}
// require NPMCI files
2016-11-25 00:07:20 +01:00
import npmci = require('../dist/index')
2016-11-15 00:07:55 +01:00
import NpmciBuildDocker = require('../dist/npmci.build.docker')
import NpmciPublish = require('../dist/npmci.publish')
import NpmciTest = require('../dist/npmci.test')
import NpmciSsh = require('../dist/npmci.ssh')
2016-06-05 13:01:45 +02:00
2016-11-15 00:07:55 +01:00
let dockerfile1: NpmciBuildDocker.Dockerfile
let dockerfile2: NpmciBuildDocker.Dockerfile
let sortableArray: NpmciBuildDocker.Dockerfile[]
2016-06-05 13:01:45 +02:00
2016-11-15 00:07:55 +01: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})
should(dockerfile1.version).equal('latest')
should(dockerfile2.version).equal('sometag1')
})
2016-06-05 13:01:45 +02:00
2016-11-15 00:07:55 +01:00
it('should read a directory of Dockerfiles',function(done){
2016-06-05 13:01:45 +02:00
NpmciBuildDocker.readDockerfiles()
2016-11-15 00:07:55 +01:00
.then(function(readDockerfilesArrayArg: NpmciBuildDocker.Dockerfile[]){
should(readDockerfilesArrayArg[1].version).equal('sometag1')
2016-06-05 13:01:45 +02:00
sortableArray = readDockerfilesArrayArg
2016-11-15 00:07:55 +01:00
done()
})
2016-06-05 13:01:45 +02:00
})
2016-11-15 00:07:55 +01:00
it('should sort an array of Dockerfiles',function(done){
2016-06-05 13:01:45 +02:00
NpmciBuildDocker.sortDockerfiles(sortableArray)
2016-11-15 00:07:55 +01:00
.then(function(sortedArrayArg: NpmciBuildDocker.Dockerfile[]){
console.log(sortedArrayArg)
done()
2016-06-05 13:01:45 +02:00
})
2016-11-15 00:07:55 +01:00
})
it('should correctly chain Dockerfile handling', function(done){
2016-06-05 14:55:08 +02:00
NpmciBuildDocker.build()
2016-11-15 00:07:55 +01:00
.then(() => {
done()
})
2016-06-05 13:01:45 +02:00
})
2016-11-15 00:07:55 +01:00
})
describe('.publish.docker',function(){
it('should publish all built Dockerfiles',function(done){
NpmciPublish.publish('docker')
2016-06-05 17:17:15 +02:00
.then(() => {
2016-11-15 00:07:55 +01:00
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')
2016-06-05 16:56:07 +02:00
.then(() => {
2016-11-15 00:07:55 +01:00
return NpmciTest.test('lts')
2016-06-05 16:56:07 +02:00
})
.then(() => {
2016-11-15 00:07:55 +01:00
return NpmciTest.test('stable')
2016-06-05 16:56:07 +02:00
})
.then(() => {
2016-11-15 00:07:55 +01:00
done()
})
2016-06-07 04:31:25 +02:00
})
2016-11-15 00:07:55 +01:00
})
describe('test.docker',function(){
it('should test dockerfiles',function(done){
NpmciTest.test('docker')
2016-06-05 16:56:07 +02:00
.then(() => {
2016-11-15 00:07:55 +01:00
done()
})
2016-06-05 16:56:07 +02:00
})
2016-11-15 00:18:32 +01:00
})
2016-11-15 00:07:55 +01:00
describe('npmci prepare ssh',function(){
it('should pick up SSH keys',function(done){
2016-06-26 02:17:17 +02:00
NpmciSsh.ssh()
.then(() => {
2016-11-15 00:07:55 +01:00
done()
2016-06-26 02:17:17 +02:00
})
})
})
2016-11-15 00:07:55 +01:00
})