1- import { InfluxDBContainer , StartedInfluxDBContainer } from "./influxdb-container" ;
2- import { getImage } from "../../../testcontainers/src/utils/test-helper" ;
31import axios from "axios" ;
2+ import { getImage } from "../../../testcontainers/src/utils/test-helper" ;
3+ import { InfluxDBContainer , StartedInfluxDBContainer } from "./influxdb-container" ;
44
55const IMAGE = getImage ( __dirname ) ;
66
77describe ( "InfluxDBContainer" , { timeout : 240_000 } , ( ) => {
8-
98 describe ( "InfluxDB 2.x" , { timeout : 240_000 } , ( ) => {
109 let container : StartedInfluxDBContainer ;
1110
@@ -66,21 +65,19 @@ describe("InfluxDBContainer", { timeout: 240_000 }, () => {
6665
6766 it ( "should be able to write and query data" , async ( ) => {
6867 const adminToken = "test-admin-token" ;
69- container = await new InfluxDBContainer ( IMAGE )
70- . withAdminToken ( adminToken )
71- . start ( ) ;
68+ container = await new InfluxDBContainer ( IMAGE ) . withAdminToken ( adminToken ) . start ( ) ;
7269
7370 // Write data using the InfluxDB 2.x API
7471 const writeUrl = `${ container . getUrl ( ) } /api/v2/write?org=${ container . getOrganization ( ) } &bucket=${ container . getBucket ( ) } ` ;
7572 const writeData = "temperature,location=room1 value=23.5" ;
76-
73+
7774 const writeResponse = await axios . post ( writeUrl , writeData , {
7875 headers : {
7976 Authorization : `Token ${ adminToken } ` ,
8077 "Content-Type" : "text/plain" ,
8178 } ,
8279 } ) ;
83-
80+
8481 expect ( writeResponse . status ) . toBe ( 204 ) ;
8582
8683 // Query data
@@ -104,7 +101,7 @@ describe("InfluxDBContainer", { timeout: 240_000 }, () => {
104101 container = await new InfluxDBContainer ( IMAGE ) . start ( ) ;
105102
106103 expect ( container . isInfluxDB2 ( ) ) . toBe ( true ) ;
107-
104+
108105 const response = await axios . get ( `${ container . getUrl ( ) } /ping` ) ;
109106 expect ( response . status ) . toBe ( 204 ) ;
110107 } ) ;
@@ -144,9 +141,7 @@ describe("InfluxDBContainer", { timeout: 240_000 }, () => {
144141 } ) ;
145142
146143 it ( "should respond to ping endpoint for v1" , async ( ) => {
147- container = await new InfluxDBContainer ( "influxdb:1.8" )
148- . withAuthEnabled ( false )
149- . start ( ) ;
144+ container = await new InfluxDBContainer ( "influxdb:1.8" ) . withAuthEnabled ( false ) . start ( ) ;
150145
151146 const response = await axios . get ( `${ container . getUrl ( ) } /ping` ) ;
152147 expect ( response . status ) . toBe ( 204 ) ;
@@ -167,21 +162,18 @@ describe("InfluxDBContainer", { timeout: 240_000 }, () => {
167162 } ) ;
168163
169164 it ( "should be able to write data with v1 API" , async ( ) => {
170- container = await new InfluxDBContainer ( "influxdb:1.8" )
171- . withDatabase ( "testdb" )
172- . withAuthEnabled ( false )
173- . start ( ) ;
165+ container = await new InfluxDBContainer ( "influxdb:1.8" ) . withDatabase ( "testdb" ) . withAuthEnabled ( false ) . start ( ) ;
174166
175167 // Write data using the InfluxDB 1.x API
176168 const writeUrl = `${ container . getUrl ( ) } /write?db=testdb` ;
177169 const writeData = "cpu_usage,host=server01 value=0.64" ;
178-
170+
179171 const writeResponse = await axios . post ( writeUrl , writeData , {
180172 headers : {
181173 "Content-Type" : "text/plain" ,
182174 } ,
183175 } ) ;
184-
176+
185177 expect ( writeResponse . status ) . toBe ( 204 ) ;
186178
187179 // Query data
@@ -207,4 +199,4 @@ describe("InfluxDBContainer", { timeout: 240_000 }, () => {
207199 await container . stop ( ) ;
208200 } ) ;
209201 } ) ;
210- } ) ;
202+ } ) ;
0 commit comments