|
@@ -21,10 +21,10 @@ describe.only('InfluxQuery', function() {
|
|
|
measurement: 'cpu',
|
|
measurement: 'cpu',
|
|
|
select: [
|
|
select: [
|
|
|
[
|
|
[
|
|
|
- {name: 'field', params: ['value']},
|
|
|
|
|
- {name: 'mean', params: []},
|
|
|
|
|
- {name: 'math', params: ['/100']},
|
|
|
|
|
- {name: 'alias', params: ['text']},
|
|
|
|
|
|
|
+ {type: 'field', params: ['value']},
|
|
|
|
|
+ {type: 'mean', params: []},
|
|
|
|
|
+ {type: 'math', params: ['/100']},
|
|
|
|
|
+ {type: 'alias', params: ['text']},
|
|
|
]
|
|
]
|
|
|
]
|
|
]
|
|
|
});
|
|
});
|
|
@@ -39,56 +39,56 @@ describe.only('InfluxQuery', function() {
|
|
|
it('should add mean after after field', function() {
|
|
it('should add mean after after field', function() {
|
|
|
var query = new InfluxQuery({
|
|
var query = new InfluxQuery({
|
|
|
measurement: 'cpu',
|
|
measurement: 'cpu',
|
|
|
- select: [[{name: 'field', params: ['value']}]]
|
|
|
|
|
|
|
+ select: [[{type: 'field', params: ['value']}]]
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
query.addSelectPart(query.selectModels[0], 'mean');
|
|
query.addSelectPart(query.selectModels[0], 'mean');
|
|
|
expect(query.target.select[0].length).to.be(2);
|
|
expect(query.target.select[0].length).to.be(2);
|
|
|
- expect(query.target.select[0][1].name).to.be('mean');
|
|
|
|
|
|
|
+ expect(query.target.select[0][1].type).to.be('mean');
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('should replace sum by mean', function() {
|
|
it('should replace sum by mean', function() {
|
|
|
var query = new InfluxQuery({
|
|
var query = new InfluxQuery({
|
|
|
measurement: 'cpu',
|
|
measurement: 'cpu',
|
|
|
- select: [[{name: 'field', params: ['value']}, {name: 'mean'}]]
|
|
|
|
|
|
|
+ select: [[{type: 'field', params: ['value']}, {type: 'mean'}]]
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
query.addSelectPart(query.selectModels[0], 'sum');
|
|
query.addSelectPart(query.selectModels[0], 'sum');
|
|
|
expect(query.target.select[0].length).to.be(2);
|
|
expect(query.target.select[0].length).to.be(2);
|
|
|
- expect(query.target.select[0][1].name).to.be('sum');
|
|
|
|
|
|
|
+ expect(query.target.select[0][1].type).to.be('sum');
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('should add math before alias', function() {
|
|
it('should add math before alias', function() {
|
|
|
var query = new InfluxQuery({
|
|
var query = new InfluxQuery({
|
|
|
measurement: 'cpu',
|
|
measurement: 'cpu',
|
|
|
- select: [[{name: 'field', params: ['value']}, {name: 'mean'}, {name: 'alias'}]]
|
|
|
|
|
|
|
+ select: [[{type: 'field', params: ['value']}, {type: 'mean'}, {type: 'alias'}]]
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
query.addSelectPart(query.selectModels[0], 'math');
|
|
query.addSelectPart(query.selectModels[0], 'math');
|
|
|
expect(query.target.select[0].length).to.be(4);
|
|
expect(query.target.select[0].length).to.be(4);
|
|
|
- expect(query.target.select[0][2].name).to.be('math');
|
|
|
|
|
|
|
+ expect(query.target.select[0][2].type).to.be('math');
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('should add math last', function() {
|
|
it('should add math last', function() {
|
|
|
var query = new InfluxQuery({
|
|
var query = new InfluxQuery({
|
|
|
measurement: 'cpu',
|
|
measurement: 'cpu',
|
|
|
- select: [[{name: 'field', params: ['value']}, {name: 'mean'}]]
|
|
|
|
|
|
|
+ select: [[{type: 'field', params: ['value']}, {type: 'mean'}]]
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
query.addSelectPart(query.selectModels[0], 'math');
|
|
query.addSelectPart(query.selectModels[0], 'math');
|
|
|
expect(query.target.select[0].length).to.be(3);
|
|
expect(query.target.select[0].length).to.be(3);
|
|
|
- expect(query.target.select[0][2].name).to.be('math');
|
|
|
|
|
|
|
+ expect(query.target.select[0][2].type).to.be('math');
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('should replace math', function() {
|
|
it('should replace math', function() {
|
|
|
var query = new InfluxQuery({
|
|
var query = new InfluxQuery({
|
|
|
measurement: 'cpu',
|
|
measurement: 'cpu',
|
|
|
- select: [[{name: 'field', params: ['value']}, {name: 'mean'}, {name: 'math'}]]
|
|
|
|
|
|
|
+ select: [[{type: 'field', params: ['value']}, {type: 'mean'}, {type: 'math'}]]
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
query.addSelectPart(query.selectModels[0], 'math');
|
|
query.addSelectPart(query.selectModels[0], 'math');
|
|
|
expect(query.target.select[0].length).to.be(3);
|
|
expect(query.target.select[0].length).to.be(3);
|
|
|
- expect(query.target.select[0][2].name).to.be('math');
|
|
|
|
|
|
|
+ expect(query.target.select[0][2].type).to.be('math');
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
});
|
|
});
|