|
|
@@ -62,30 +62,48 @@ define([
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- describe('when building tag keys query', function() {
|
|
|
-
|
|
|
- describe('given picked measurement', function() {
|
|
|
- it('build query with measurement filter', function() {
|
|
|
- var builder = new InfluxQueryBuilder({ measurement: 'cpu', tags: [] });
|
|
|
- var query = builder.showTagsQuery();
|
|
|
- expect(query).to.be('SHOW TAG KEYS FROM "cpu"');
|
|
|
- });
|
|
|
+ describe('when building explore queries', function() {
|
|
|
+
|
|
|
+ it('should only have measurement condition in tag keys query given query with measurement', function() {
|
|
|
+ var builder = new InfluxQueryBuilder({ measurement: 'cpu', tags: [] });
|
|
|
+ var query = builder.buildExploreQuery('TAG_KEYS');
|
|
|
+ expect(query).to.be('SHOW TAG KEYS FROM "cpu"');
|
|
|
+ });
|
|
|
+
|
|
|
+ it('should have no conditions in tags keys query given query with no measurement or tag', function() {
|
|
|
+ var builder = new InfluxQueryBuilder({ measurement: '', tags: [] });
|
|
|
+ var query = builder.buildExploreQuery('TAG_KEYS');
|
|
|
+ expect(query).to.be('SHOW TAG KEYS');
|
|
|
+ });
|
|
|
+
|
|
|
+ it('should have where condition in tag keys query with tags', function() {
|
|
|
+ var builder = new InfluxQueryBuilder({ measurement: '', tags: [{key: 'host', value: 'se1'}] });
|
|
|
+ var query = builder.buildExploreQuery('TAG_KEYS');
|
|
|
+ expect(query).to.be("SHOW TAG KEYS WHERE host='se1'");
|
|
|
+ });
|
|
|
+
|
|
|
+ it('should have no conditions in measurement query for query with no tags', function() {
|
|
|
+ var builder = new InfluxQueryBuilder({ measurement: '', tags: [] });
|
|
|
+ var query = builder.buildExploreQuery('MEASUREMENTS');
|
|
|
+ expect(query).to.be('SHOW MEASUREMENTS');
|
|
|
+ });
|
|
|
+
|
|
|
+ it('should have where condition in measurement query for query with tags', function() {
|
|
|
+ var builder = new InfluxQueryBuilder({measurement: '', tags: [{key: 'app', value: 'email'}]});
|
|
|
+ var query = builder.buildExploreQuery('MEASUREMENTS');
|
|
|
+ expect(query).to.be("SHOW MEASUREMENTS WHERE app='email'");
|
|
|
});
|
|
|
|
|
|
- describe('given no picked measurement', function() {
|
|
|
- it('build query without filter', function() {
|
|
|
- var builder = new InfluxQueryBuilder({ measurement: '', tags: [] });
|
|
|
- var query = builder.showTagsQuery();
|
|
|
- expect(query).to.be('SHOW TAG KEYS');
|
|
|
- });
|
|
|
+ it('should have where tag name IN filter in tag values query for query with one tag', function() {
|
|
|
+ var builder = new InfluxQueryBuilder({measurement: '', tags: [{key: 'app', value: 'asdsadsad'}]});
|
|
|
+ var query = builder.buildExploreQuery('TAG_VALUES', 'app');
|
|
|
+ expect(query).to.be('SHOW TAG VALUES WITH KEY = "app"');
|
|
|
});
|
|
|
|
|
|
- describe('given an existing tag', function() {
|
|
|
- it('build query with filter', function() {
|
|
|
- var builder = new InfluxQueryBuilder({ measurement: '', tags: [{key: 'host', value: 'se1'}] });
|
|
|
- var query = builder.showTagsQuery();
|
|
|
- expect(query).to.be('SHOW TAG KEYS');
|
|
|
- });
|
|
|
+ it('should have measurement tag condition and tag name IN filter in tag values query', function() {
|
|
|
+ var builder = new InfluxQueryBuilder({measurement: 'cpu', tags: [{key: 'app', value: 'email'}, {key: 'host', value: 'server1'}]});
|
|
|
+ var query = builder.buildExploreQuery('TAG_VALUES', 'app');
|
|
|
+ expect(query).to.be('SHOW TAG VALUES FROM "cpu" WITH KEY = "app" WHERE host=\'server1\'');
|
|
|
});
|
|
|
|
|
|
});
|