| 
									
										
										
										
											2021-12-19 23:46:04 +00:00
										 |  |  | import { BuildParameters, ImageTag } from '..'; | 
					
						
							|  |  |  | import CloudRunner from './cloud-runner'; | 
					
						
							|  |  |  | import Input from '../input'; | 
					
						
							| 
									
										
										
										
											2021-12-20 19:31:09 +00:00
										 |  |  | import fs from 'fs'; | 
					
						
							|  |  |  | import { CloudRunnerState } from './state/cloud-runner-state'; | 
					
						
							| 
									
										
										
										
											2021-12-19 23:46:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-20 00:22:47 +00:00
										 |  |  | describe('Cloud Runner', () => { | 
					
						
							|  |  |  |   it('responds', () => {}); | 
					
						
							|  |  |  | }); | 
					
						
							| 
									
										
										
										
											2021-12-20 19:15:27 +00:00
										 |  |  | describe('Cloud Runner', () => { | 
					
						
							| 
									
										
										
										
											2021-12-20 00:04:46 +00:00
										 |  |  |   Input.cliOptions = { | 
					
						
							|  |  |  |     versioning: 'None', | 
					
						
							|  |  |  |     projectPath: 'test-project', | 
					
						
							|  |  |  |     customBuildSteps: `
 | 
					
						
							|  |  |  |     - name: 'step 1' | 
					
						
							|  |  |  |       image: 'alpine' | 
					
						
							|  |  |  |       commands: ['printenv'] | 
					
						
							|  |  |  |       secrets: | 
					
						
							|  |  |  |         - name: 'testCustomSecret' | 
					
						
							|  |  |  |           value: 'VALUEXXX' | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  |   Input.githubEnabled = false; | 
					
						
							| 
									
										
										
										
											2021-12-20 19:47:54 +00:00
										 |  |  |   it('All build parameters sent to cloud runner as env vars', async () => { | 
					
						
							| 
									
										
										
										
											2021-12-20 19:15:27 +00:00
										 |  |  |     if (Input.remoteBuilderIntegrationTests) { | 
					
						
							|  |  |  |       const buildParameter = await BuildParameters.create(); | 
					
						
							|  |  |  |       buildParameter.logToFile = true; | 
					
						
							|  |  |  |       const baseImage = new ImageTag(buildParameter); | 
					
						
							|  |  |  |       await CloudRunner.run(buildParameter, baseImage.toString()); | 
					
						
							| 
									
										
										
										
											2021-12-23 23:26:07 +00:00
										 |  |  |       const file = fs.readFileSync(`${CloudRunnerState.buildGuid}-outputfile.txt`, 'utf-8').toString(); | 
					
						
							| 
									
										
										
										
											2021-12-23 17:54:08 +00:00
										 |  |  |       expect(file).toContain(JSON.stringify(buildParameter)); | 
					
						
							| 
									
										
										
										
											2021-12-23 01:37:03 +00:00
										 |  |  |       const inputKeys = Object.getOwnPropertyNames(Input); | 
					
						
							|  |  |  |       for (const element of inputKeys) { | 
					
						
							| 
									
										
										
										
											2021-12-23 19:05:45 +00:00
										 |  |  |         if (Input[element] !== undefined && typeof Input[element] != 'function') { | 
					
						
							| 
									
										
										
										
											2021-12-24 03:32:02 +00:00
										 |  |  |           expect(file.replace(/\s+/g, '').replace(new RegExp(`[Cloud-Runner-Agent]`, 'g'), 'replace')).toContain( | 
					
						
							| 
									
										
										
										
											2021-12-24 03:18:44 +00:00
										 |  |  |             `${element}=${Input[element].toString().replace(/\s+/g, '')}`, | 
					
						
							|  |  |  |           ); | 
					
						
							| 
									
										
										
										
											2021-12-21 05:57:00 +00:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2021-12-20 19:47:54 +00:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2021-12-20 19:15:27 +00:00
										 |  |  |     } | 
					
						
							|  |  |  |   }, 500000); | 
					
						
							|  |  |  | }); |