mirror of
				https://github.com/grafana/grafana.git
				synced 2025-02-25 18:55:37 -06:00 
			
		
		
		
	test(influxdb): adds tests for supporting multiple tags
This commit is contained in:
		@@ -89,7 +89,7 @@ function (_, TableModel) {
 | 
				
			|||||||
        if (column === 'sequence_number') { return; }
 | 
					        if (column === 'sequence_number') { return; }
 | 
				
			||||||
        if (!titleCol) { titleCol = index; }
 | 
					        if (!titleCol) { titleCol = index; }
 | 
				
			||||||
        if (column === self.annotation.titleColumn) { titleCol = index; return; }
 | 
					        if (column === self.annotation.titleColumn) { titleCol = index; return; }
 | 
				
			||||||
        if (_.contains(tagsColumn.split(","), column)) { tagsCol.push(index); return; }
 | 
					        if (_.includes(self.annotation.tagsColumn.replace(' ', '').split(","), column)) { tagsCol.push(index); return; }
 | 
				
			||||||
        if (column === self.annotation.textColumn) { textCol = index; return; }
 | 
					        if (column === self.annotation.textColumn) { textCol = index; return; }
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,7 +2,6 @@ import {describe, beforeEach, it, sinon, expect} from 'test/lib/common';
 | 
				
			|||||||
import InfluxSeries from '../influx_series';
 | 
					import InfluxSeries from '../influx_series';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
describe('when generating timeseries from influxdb response', function() {
 | 
					describe('when generating timeseries from influxdb response', function() {
 | 
				
			||||||
 | 
					 | 
				
			||||||
  describe('given multiple fields for series', function() {
 | 
					  describe('given multiple fields for series', function() {
 | 
				
			||||||
    var options = {
 | 
					    var options = {
 | 
				
			||||||
      alias: '',
 | 
					      alias: '',
 | 
				
			||||||
@@ -68,6 +67,7 @@ describe('when generating timeseries from influxdb response', function() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  describe('given measurement with default fieldname', function() {
 | 
					  describe('given measurement with default fieldname', function() {
 | 
				
			||||||
    var options = { series: [
 | 
					    var options = { series: [
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
@@ -96,6 +96,7 @@ describe('when generating timeseries from influxdb response', function() {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  describe('given two series', function() {
 | 
					  describe('given two series', function() {
 | 
				
			||||||
    var options = {
 | 
					    var options = {
 | 
				
			||||||
      alias: '',
 | 
					      alias: '',
 | 
				
			||||||
@@ -206,5 +207,32 @@ describe('when generating timeseries from influxdb response', function() {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  describe('given annotation response', function() {
 | 
				
			||||||
 | 
					    var options = {
 | 
				
			||||||
 | 
					      alias: '',
 | 
				
			||||||
 | 
					      annotation: {
 | 
				
			||||||
 | 
					        tagsColumn: 'datacenter, source'
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					      series: [
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          name: "logins.count",
 | 
				
			||||||
 | 
					          tags:  {datacenter: 'Africa', server: 'server2'},
 | 
				
			||||||
 | 
					          columns: ["time", "datacenter", "hostname", "source", "value"],
 | 
				
			||||||
 | 
					          values: [
 | 
				
			||||||
 | 
					            [1481549440372, "America", "10.1.100.10", "backend", 215.7432653659507],
 | 
				
			||||||
 | 
					          ]
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      ]
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    it('should multiple tags', function() {
 | 
				
			||||||
 | 
					      var series = new InfluxSeries(options);
 | 
				
			||||||
 | 
					      var annotations = series.getAnnotations();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      expect(annotations[0].tags.length).to.be(2);
 | 
				
			||||||
 | 
					      expect(annotations[0].tags[0]).to.be('America');
 | 
				
			||||||
 | 
					      expect(annotations[0].tags[1]).to.be('backend');
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user