npmci/test/test.ts

80 lines
2.4 KiB
TypeScript
Raw Normal View History

import { tap, expect } from 'tapbundle'
2016-11-24 22:21:40 +00:00
import * as path from 'path'
2016-11-14 23:07:55 +00: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 11:01:45 +00:00
process.cwd = () => {
return path.join(__dirname, 'assets/')
2016-11-14 23:07:55 +00:00
}
// require NPMCI files
2016-11-24 23:07:20 +00:00
import npmci = require('../dist/index')
2016-11-14 23:07:55 +00: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 11:01:45 +00:00
2016-11-14 23:07:55 +00:00
let dockerfile1: NpmciBuildDocker.Dockerfile
let dockerfile2: NpmciBuildDocker.Dockerfile
let sortableArray: NpmciBuildDocker.Dockerfile[]
2016-06-05 11:01:45 +00:00
tap.test('should return valid Dockerfiles', async () => {
dockerfile1 = new NpmciBuildDocker.Dockerfile({ filePath: './Dockerfile', read: true })
dockerfile2 = new NpmciBuildDocker.Dockerfile({ filePath: './Dockerfile_sometag1', read: true })
expect(dockerfile1.version).to.equal('latest')
return expect(dockerfile2.version).to.equal('sometag1')
2017-05-15 12:19:56 +00:00
})
2016-11-14 23:07:55 +00:00
tap.test('should read a directory of Dockerfiles', async () => {
return NpmciBuildDocker.readDockerfiles()
.then(async (readDockerfilesArrayArg: NpmciBuildDocker.Dockerfile[]) => {
sortableArray = readDockerfilesArrayArg
return expect(readDockerfilesArrayArg[ 1 ].version).to.equal('sometag1')
2016-11-14 23:07:55 +00:00
})
2017-05-15 12:19:56 +00:00
})
2016-11-14 23:07:55 +00:00
tap.test('should sort an array of Dockerfiles', async () => {
return NpmciBuildDocker.sortDockerfiles(sortableArray)
.then(async (sortedArrayArg: NpmciBuildDocker.Dockerfile[]) => {
console.log(sortedArrayArg)
2016-11-14 23:07:55 +00:00
})
2017-05-15 12:19:56 +00:00
})
2016-11-14 23:07:55 +00:00
tap.test('should correctly chain Dockerfile handling', async () => {
return NpmciBuildDocker.build()
2017-05-15 12:19:56 +00:00
})
2016-11-14 23:07:55 +00:00
tap.test('should publish all built Dockerfiles', async () => {
return NpmciPublish.publish('docker')
2017-05-15 12:19:56 +00:00
})
2016-11-14 23:18:32 +00:00
tap.test('should source nvm using bash and install a specific node version, then test it', async () => {
return NpmciTest.test('legacy')
.then(() => {
return NpmciTest.test('lts')
})
.then(() => {
return NpmciTest.test('stable')
2016-06-26 00:17:17 +00:00
})
2017-05-15 12:19:56 +00:00
})
tap.test('should test dockerfiles', async () => {
return NpmciTest.test('docker')
2017-05-15 12:19:56 +00:00
})
tap.test('should pick up SSH keys', async () => {
return NpmciSsh.ssh()
2017-05-15 12:19:56 +00:00
})
tap.test('reset paths', async () => {
process.cwd = () => {
return path.join(__dirname, '../')
}
2017-05-15 12:19:56 +00:00
})
tap.start()