forked from opensearch-project/dashboards-observability
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move convertDateTime, refactor query_utils (opensearch-project#1064)
Signed-off-by: Peter Fitzgibbons <[email protected]>
- Loading branch information
1 parent
6882751
commit 3d85b2d
Showing
8 changed files
with
392 additions
and
234 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
public/components/common/query_utils/__tests__/query_utils.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { parsePromQLIntoKeywords } from '../'; | ||
|
||
describe('Query Utils', () => { | ||
describe('parsePromQLIntoKeywords', () => { | ||
test('should parse plain catalog.metric into keywords', () => { | ||
const query = 'catalog.metric'; | ||
const keywords = parsePromQLIntoKeywords(query); | ||
expect(keywords).toEqual({ | ||
aggregation: 'avg', | ||
attributesGroupBy: '', | ||
connection: 'catalog', | ||
metric: 'metric', | ||
}); | ||
}); | ||
|
||
test('should parse simple ppl query_range into keywords', () => { | ||
console.log('should parse simple ppl query_range into keywords'); | ||
const query = "source = test_catalog.query_range('metric')"; | ||
const keywords = parsePromQLIntoKeywords(query); | ||
expect(keywords).toEqual({ | ||
aggregation: 'avg', | ||
attributesGroupBy: '', | ||
connection: 'test_catalog', | ||
metric: 'metric', | ||
}); | ||
}); | ||
|
||
test('should parse promql into keywords', () => { | ||
console.log('should parse promql into keywords'); | ||
const query = "source = test_catalog.query_range('count by(one,two) (metric)')"; | ||
const keywords = parsePromQLIntoKeywords(query); | ||
expect(keywords).toEqual({ | ||
aggregation: 'count', | ||
attributesGroupBy: 'one,two', | ||
connection: 'test_catalog', | ||
metric: 'metric', | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.