| 
									
										
										
										
											2017-04-02 22:56:40 +02:00
										 |  |  | import { tap, expect } from 'tapbundle' | 
					
						
							| 
									
										
										
										
											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 = () => { | 
					
						
							| 
									
										
										
										
											2017-04-02 22:56:40 +02:00
										 |  |  |   return path.join(__dirname, 'assets/') | 
					
						
							| 
									
										
										
										
											2016-11-15 00:07:55 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // 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
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-02 22:56:40 +02: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') | 
					
						
							|  |  |  | }).catch(tap.threw) | 
					
						
							| 
									
										
										
										
											2016-11-15 00:07:55 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-02 22:56:40 +02: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-15 00:07:55 +01:00
										 |  |  |     }) | 
					
						
							| 
									
										
										
										
											2017-04-02 22:56:40 +02:00
										 |  |  | }).catch(tap.threw) | 
					
						
							| 
									
										
										
										
											2016-11-15 00:07:55 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-02 22:56:40 +02:00
										 |  |  | tap.test('should sort an array of Dockerfiles', async () => { | 
					
						
							|  |  |  |   return NpmciBuildDocker.sortDockerfiles(sortableArray) | 
					
						
							|  |  |  |     .then(async (sortedArrayArg: NpmciBuildDocker.Dockerfile[]) => { | 
					
						
							|  |  |  |       console.log(sortedArrayArg) | 
					
						
							| 
									
										
										
										
											2016-11-15 00:07:55 +01:00
										 |  |  |     }) | 
					
						
							| 
									
										
										
										
											2017-04-02 22:56:40 +02:00
										 |  |  | }).catch(tap.threw) | 
					
						
							| 
									
										
										
										
											2016-11-15 00:07:55 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-02 22:56:40 +02:00
										 |  |  | tap.test('should correctly chain Dockerfile handling', async () => { | 
					
						
							|  |  |  |   return NpmciBuildDocker.build() | 
					
						
							|  |  |  | }).catch(tap.threw) | 
					
						
							| 
									
										
										
										
											2016-11-15 00:07:55 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-02 22:56:40 +02:00
										 |  |  | tap.test('should publish all built Dockerfiles', async () => { | 
					
						
							|  |  |  |   return NpmciPublish.publish('docker') | 
					
						
							|  |  |  | }).catch(tap.threw) | 
					
						
							| 
									
										
										
										
											2016-11-15 00:18:32 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-02 22:56:40 +02: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 02:17:17 +02:00
										 |  |  |     }) | 
					
						
							| 
									
										
										
										
											2017-04-02 22:56:40 +02:00
										 |  |  | }).catch(tap.threw) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | tap.test('should test dockerfiles', async () => { | 
					
						
							|  |  |  |   return NpmciTest.test('docker') | 
					
						
							|  |  |  | }).catch(tap.threw) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | tap.test('should pick up SSH keys', async () => { | 
					
						
							|  |  |  |   return NpmciSsh.ssh() | 
					
						
							|  |  |  | }).catch(tap.threw) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | tap.test('reset paths', async () => { | 
					
						
							|  |  |  |   process.cwd = () => { | 
					
						
							|  |  |  |     return path.join(__dirname, '../') | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | }) |