npmci/test/test.ts

104 lines
2.6 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
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 = () => {
return path.join(__dirname, 'assets/')
2016-11-14 23:07:55 +00:00
}
// require NPMCI files
2017-05-19 10:09:33 +00:00
import '../dist/index'
import NpmciBuildDocker = require('../dist/mod_docker/index')
import NpmciPublish = require('../dist/mod_publish/index')
import NpmciTest = require('../dist/mod_test/index')
2017-06-15 13:46:08 +00:00
import NpmciSsh = require('../dist/mod_ssh/index')
2017-05-25 11:01:17 +00:00
import NpmciEnv = require('../dist/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
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({
_: [
'test',
'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 () => {
await NpmciTest.test({
_: [
'test',
'legacy'
]
})
await NpmciTest.test({
_: [
'test',
'lts'
]
})
await NpmciTest.test({
_: [
'test',
'stable'
]
})
2017-05-15 12:19:56 +00:00
})
tap.test('should test dockerfiles', async () => {
return NpmciTest.test({
_: [
'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
})
2017-05-25 11:01:17 +00:00
tap.test('', async () => {
await NpmciEnv.configStore()
})
2017-05-15 12:19:56 +00:00
tap.start()