| 
									
										
										
										
											2018-08-12 16:42:09 +02:00
										 |  |  | import { expect, tap } from '@pushrocks/tapbundle'; | 
					
						
							| 
									
										
										
										
											2018-11-03 20:01:39 +01:00
										 |  |  | import { Qenv } from '@pushrocks/qenv'; | 
					
						
							| 
									
										
										
										
											2018-11-07 11:38:53 +01:00
										 |  |  | import * as elasticsearch from '../ts/index'; | 
					
						
							| 
									
										
										
										
											2018-01-25 00:38:07 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-12 16:42:09 +02:00
										 |  |  | const testQenv = new Qenv('./', './.nogit/'); | 
					
						
							| 
									
										
										
										
											2018-01-25 00:38:07 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-07 11:38:53 +01:00
										 |  |  | let testElasticLog: elasticsearch.ElasticSearch<any>; | 
					
						
							| 
									
										
										
										
											2018-01-25 00:38:07 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | tap.test('first test', async () => { | 
					
						
							| 
									
										
										
										
											2018-11-07 11:38:53 +01:00
										 |  |  |   testElasticLog = new elasticsearch.ElasticSearch({ | 
					
						
							| 
									
										
										
										
											2018-11-10 01:48:44 +01:00
										 |  |  |     indexPrefix: 'smartlog', | 
					
						
							|  |  |  |     indexRetention: 7, | 
					
						
							| 
									
										
										
										
											2019-11-02 01:42:03 +01:00
										 |  |  |     domain: testQenv.getEnvVarOnDemand('ELK_DOMAIN'), | 
					
						
							|  |  |  |     port: parseInt(testQenv.getEnvVarOnDemand('ELK_PORT'), 10), | 
					
						
							|  |  |  |     ssl: true | 
					
						
							| 
									
										
										
										
											2018-08-12 16:42:09 +02:00
										 |  |  |   }); | 
					
						
							| 
									
										
										
										
											2018-11-07 11:38:53 +01:00
										 |  |  |   expect(testElasticLog).to.be.instanceOf(elasticsearch.ElasticSearch); | 
					
						
							| 
									
										
										
										
											2018-08-12 16:42:09 +02:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2018-01-25 00:38:07 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-03 20:01:39 +01:00
										 |  |  | tap.test('should send a message to Elasticsearch', async () => { | 
					
						
							| 
									
										
										
										
											2018-01-25 00:38:07 +01:00
										 |  |  |   testElasticLog.log({ | 
					
						
							| 
									
										
										
										
											2018-11-07 11:38:53 +01:00
										 |  |  |     timestamp: Date.now(), | 
					
						
							| 
									
										
										
										
											2018-11-03 23:45:21 +01:00
										 |  |  |     type: 'increment', | 
					
						
							|  |  |  |     level: 'info', | 
					
						
							|  |  |  |     context: { | 
					
						
							|  |  |  |       company: 'Lossless GmbH', | 
					
						
							|  |  |  |       companyunit: 'lossless.cloud', | 
					
						
							|  |  |  |       containerName: 'testcontainer', | 
					
						
							|  |  |  |       environment: 'test', | 
					
						
							|  |  |  |       runtime: 'node', | 
					
						
							| 
									
										
										
										
											2018-11-07 11:38:53 +01:00
										 |  |  |       zone: 'ship.zone' | 
					
						
							| 
									
										
										
										
											2018-11-03 23:45:21 +01:00
										 |  |  |     }, | 
					
						
							| 
									
										
										
										
											2019-11-03 00:47:18 +01:00
										 |  |  |     message: 'GET https://myroute.to.a.cool.destination/sorare?hello=there' | 
					
						
							| 
									
										
										
										
											2018-08-12 16:42:09 +02:00
										 |  |  |   }); | 
					
						
							|  |  |  | }); | 
					
						
							| 
									
										
										
										
											2018-01-25 00:38:07 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-12 16:42:09 +02:00
										 |  |  | tap.start(); |