2017-04-02 20:56:40 +00:00
|
|
|
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
|
2017-05-15 16:27:13 +00:00
|
|
|
process.env.CI_REPOSITORY_URL = 'https://yyyyyy:xxxxxxxx@gitlab.com/mygroup/myrepo.git'
|
2016-11-14 23:07:55 +00:00
|
|
|
process.env.NPMCI_SSHKEY_1 = 'hostString|somePrivKey|##'
|
|
|
|
process.env.NPMTS_TEST = 'true'
|
2016-06-05 11:01:45 +00:00
|
|
|
process.cwd = () => {
|
2017-04-02 20:56:40 +00:00
|
|
|
return path.join(__dirname, 'assets/')
|
2016-11-14 23:07:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// require NPMCI files
|
2017-08-25 19:07:02 +00:00
|
|
|
import '../ts/index'
|
|
|
|
import NpmciBuildDocker = require('../ts/mod_docker/index')
|
|
|
|
import NpmciPublish = require('../ts/mod_publish/index')
|
|
|
|
import NpmciTest = require('../ts/mod_test/index')
|
|
|
|
import NpmciSsh = require('../ts/mod_ssh/index')
|
|
|
|
import NpmciEnv = require('../ts/npmci.env')
|
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
|
|
|
|
2017-04-02 20:56:40 +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
|
|
|
|
2017-04-02 20:56:40 +00:00
|
|
|
tap.test('should read a directory of Dockerfiles', async () => {
|
2017-07-27 12:20:56 +00:00
|
|
|
return NpmciBuildDocker.readDockerfiles({})
|
2017-04-02 20:56:40 +00:00
|
|
|
.then(async (readDockerfilesArrayArg: NpmciBuildDocker.Dockerfile[]) => {
|
|
|
|
sortableArray = readDockerfilesArrayArg
|
2017-07-27 12:20:56 +00:00
|
|
|
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
|
|
|
|
2017-04-02 20:56:40 +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
|
|
|
|
2017-04-02 20:56:40 +00:00
|
|
|
tap.test('should correctly chain Dockerfile handling', async () => {
|
2017-07-27 11:15:39 +00:00
|
|
|
return NpmciBuildDocker.build({})
|
2017-05-15 12:19:56 +00:00
|
|
|
})
|
2016-11-14 23:07:55 +00:00
|
|
|
|
2017-04-02 20:56:40 +00:00
|
|
|
tap.test('should publish all built Dockerfiles', async () => {
|
2017-07-27 12:20:56 +00:00
|
|
|
return NpmciPublish.publish({
|
|
|
|
_: [
|
|
|
|
'test',
|
|
|
|
'docker'
|
|
|
|
]
|
|
|
|
})
|
2017-05-15 12:19:56 +00:00
|
|
|
})
|
2016-11-14 23:18:32 +00:00
|
|
|
|
2017-04-02 20:56:40 +00:00
|
|
|
tap.test('should source nvm using bash and install a specific node version, then test it', async () => {
|
2017-07-27 12:20:56 +00:00
|
|
|
await NpmciTest.test({
|
|
|
|
_: [
|
|
|
|
'test',
|
|
|
|
'legacy'
|
|
|
|
]
|
|
|
|
})
|
|
|
|
await NpmciTest.test({
|
|
|
|
_: [
|
|
|
|
'test',
|
|
|
|
'lts'
|
|
|
|
]
|
|
|
|
})
|
|
|
|
await NpmciTest.test({
|
|
|
|
_: [
|
|
|
|
'test',
|
|
|
|
'stable'
|
|
|
|
]
|
|
|
|
})
|
2017-05-15 12:19:56 +00:00
|
|
|
})
|
2017-04-02 20:56:40 +00:00
|
|
|
|
|
|
|
tap.test('should test dockerfiles', async () => {
|
2017-07-27 12:20:56 +00:00
|
|
|
return NpmciTest.test({
|
|
|
|
_: [
|
|
|
|
'test',
|
|
|
|
'docker'
|
|
|
|
]
|
|
|
|
})
|
2017-05-15 12:19:56 +00:00
|
|
|
})
|
2017-04-02 20:56:40 +00:00
|
|
|
|
|
|
|
tap.test('should pick up SSH keys', async () => {
|
|
|
|
return NpmciSsh.ssh()
|
2017-05-15 12:19:56 +00:00
|
|
|
})
|
2017-04-02 20:56:40 +00:00
|
|
|
|
|
|
|
tap.test('reset paths', async () => {
|
|
|
|
process.cwd = () => {
|
|
|
|
return path.join(__dirname, '../')
|
|
|
|
}
|
2017-05-15 12:19:56 +00:00
|
|
|
})
|
|
|
|
|
2017-05-25 11:01:17 +00:00
|
|
|
tap.test('', async () => {
|
|
|
|
await NpmciEnv.configStore()
|
|
|
|
})
|
|
|
|
|
2017-05-15 12:19:56 +00:00
|
|
|
tap.start()
|