@ -205,7 +205,6 @@ describe('InfluxQuery', () => {
expect ( queryText ) . toBe ( 'SELECT mean("value") FROM "autogen"."cpu" WHERE ("value" > 5) AND $timeFilter' ) ;
} ) ;
} ) ;
describe ( 'query with greater-than-or-equal-to condition' , ( ) = > {
it ( 'should use >=' , ( ) = > {
const query = new InfluxQueryModel (
@ -244,6 +243,158 @@ describe('InfluxQuery', () => {
} ) ;
} ) ;
describe ( 'query with Is operator' , ( ) = > {
it ( 'should use =' , ( ) = > {
const query = new InfluxQueryModel (
{
refId : 'A' ,
measurement : 'cpu' ,
policy : 'autogen' ,
groupBy : [ ] ,
tags : [ { key : 'value' , value : 'False' , operator : 'Is' } ] ,
} ,
templateSrv ,
{ }
) ;
const queryText = query . render ( ) ;
expect ( queryText ) . toBe ( 'SELECT mean("value") FROM "autogen"."cpu" WHERE ("value" = false) AND $timeFilter' ) ;
} ) ;
} ) ;
describe ( 'query with Is Not operator' , ( ) = > {
it ( 'should use !=' , ( ) = > {
const query = new InfluxQueryModel (
{
refId : 'A' ,
measurement : 'cpu' ,
policy : 'autogen' ,
groupBy : [ ] ,
tags : [ { key : 'value' , value : 'False' , operator : 'Is Not' } ] ,
} ,
templateSrv ,
{ }
) ;
const queryText = query . render ( ) ;
expect ( queryText ) . toBe ( 'SELECT mean("value") FROM "autogen"."cpu" WHERE ("value" != false) AND $timeFilter' ) ;
} ) ;
} ) ;
describe ( 'query with Is boolean condition' , ( ) = > {
it ( 'should convert to lowercase and not quote value' , ( ) = > {
const query = new InfluxQueryModel (
{
refId : 'A' ,
measurement : 'cpu' ,
policy : 'autogen' ,
groupBy : [ ] ,
tags : [ { key : 'value' , value : 'True' , operator : 'Is' } ] ,
} ,
templateSrv ,
{ }
) ;
const queryText = query . render ( ) ;
expect ( queryText ) . toBe ( 'SELECT mean("value") FROM "autogen"."cpu" WHERE ("value" = true) AND $timeFilter' ) ;
} ) ;
} ) ;
describe ( 'query with Is string condition' , ( ) = > {
it ( 'should quote value' , ( ) = > {
const query = new InfluxQueryModel (
{
refId : 'A' ,
measurement : 'cpu' ,
policy : 'autogen' ,
groupBy : [ ] ,
tags : [ { key : 'value' , value : 'Server2' , operator : 'Is' } ] ,
} ,
templateSrv ,
{ }
) ;
const queryText = query . render ( ) ;
expect ( queryText ) . toBe ( 'SELECT mean("value") FROM "autogen"."cpu" WHERE ("value" = \'Server2\') AND $timeFilter' ) ;
} ) ;
} ) ;
describe ( 'query with Is integer condition' , ( ) = > {
it ( 'should not quote value' , ( ) = > {
const query = new InfluxQueryModel (
{
refId : 'A' ,
measurement : 'cpu' ,
policy : 'autogen' ,
groupBy : [ ] ,
tags : [ { key : 'value' , value : '5' , operator : 'Is' } ] ,
} ,
templateSrv ,
{ }
) ;
const queryText = query . render ( ) ;
expect ( queryText ) . toBe ( 'SELECT mean("value") FROM "autogen"."cpu" WHERE ("value" = 5) AND $timeFilter' ) ;
} ) ;
} ) ;
describe ( 'query with Is float condition' , ( ) = > {
it ( 'should not quote value' , ( ) = > {
const query = new InfluxQueryModel (
{
refId : 'A' ,
measurement : 'cpu' ,
policy : 'autogen' ,
groupBy : [ ] ,
tags : [ { key : 'value' , value : '1.234' , operator : 'Is' } ] ,
} ,
templateSrv ,
{ }
) ;
const queryText = query . render ( ) ;
expect ( queryText ) . toBe ( 'SELECT mean("value") FROM "autogen"."cpu" WHERE ("value" = 1.234) AND $timeFilter' ) ;
} ) ;
} ) ;
describe ( 'query with Is negative float condition' , ( ) = > {
it ( 'should not quote value' , ( ) = > {
const query = new InfluxQueryModel (
{
refId : 'A' ,
measurement : 'cpu' ,
policy : 'autogen' ,
groupBy : [ ] ,
tags : [ { key : 'value' , value : '-1.234' , operator : 'Is' } ] ,
} ,
templateSrv ,
{ }
) ;
const queryText = query . render ( ) ;
expect ( queryText ) . toBe ( 'SELECT mean("value") FROM "autogen"."cpu" WHERE ("value" = -1.234) AND $timeFilter' ) ;
} ) ;
} ) ;
describe ( 'query with Is boolean condition' , ( ) = > {
it ( 'should convert to lowercase and not quote value' , ( ) = > {
const query = new InfluxQueryModel (
{
refId : 'A' ,
measurement : 'cpu' ,
policy : 'autogen' ,
groupBy : [ ] ,
tags : [ { key : 'value' , value : 'True' , operator : 'Is' } ] ,
} ,
templateSrv ,
{ }
) ;
const queryText = query . render ( ) ;
expect ( queryText ) . toBe ( 'SELECT mean("value") FROM "autogen"."cpu" WHERE ("value" = true) AND $timeFilter' ) ;
} ) ;
} ) ;
describe ( 'series with groupByTag' , ( ) = > {
it ( 'should generate correct query' , ( ) = > {
const query = new InfluxQueryModel (