Skip to content

Commit

Permalink
Add tests for new query syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
prymitive committed Nov 19, 2024
1 parent 9e1eb4c commit d16f832
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/spellcheck/wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ unmarshal
uptime
URI
URIs
UTF
validator
VCS
yaml
Expand Down
12 changes: 12 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## v0.68.0

### Changed

- pint now uses [Prometheus 3.0](https://prometheus.io/blog/2024/11/14/prometheus-3-0/) libraries
for parsing PromQL, which adds support for new query syntax that allows for dots and UTF-8 chars
in metric/label names, example:

```js
{"status.üp"} == 0
```

## v0.67.3

### Fixed
Expand Down
82 changes: 82 additions & 0 deletions internal/parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2798,6 +2798,88 @@ groups:
`),
strict: true,
},
{
content: []byte(`
groups:
- name: foo
rules:
- record: foo
expr: |
{"up"}
`),
output: []parser.Rule{
{
Lines: parser.LineRange{First: 5, Last: 7},
RecordingRule: &parser.RecordingRule{
Record: parser.YamlNode{
Lines: parser.LineRange{First: 5, Last: 5},
Value: "foo",
},
Expr: parser.PromQLExpr{
Value: &parser.YamlNode{
Lines: parser.LineRange{First: 6, Last: 7},
Value: "{\"up\"}\n",
},
},
},
},
},
},
{
content: []byte(`
groups:
- name: foo
rules:
- record: foo
expr: |
{'up'}
`),
output: []parser.Rule{
{
Lines: parser.LineRange{First: 5, Last: 7},
RecordingRule: &parser.RecordingRule{
Record: parser.YamlNode{
Lines: parser.LineRange{First: 5, Last: 5},
Value: "foo",
},
Expr: parser.PromQLExpr{
Value: &parser.YamlNode{
Lines: parser.LineRange{First: 6, Last: 7},
Value: "{'up'}\n",
},
},
},
},
},
},
{
content: []byte(`
groups:
- name: foo
rules:
- record: foo
expr: |
{'up' == 1}
`),
output: []parser.Rule{
{
Lines: parser.LineRange{First: 5, Last: 7},
RecordingRule: &parser.RecordingRule{
Record: parser.YamlNode{
Lines: parser.LineRange{First: 5, Last: 5},
Value: "foo",
},
Expr: parser.PromQLExpr{
Value: &parser.YamlNode{
Lines: parser.LineRange{First: 6, Last: 7},
Value: "{'up' == 1}\n",
},
SyntaxError: errors.New("unexpected character inside braces: '1'"),
},
},
},
},
},
}

alwaysEqual := cmp.Comparer(func(_, _ interface{}) bool { return true })
Expand Down

0 comments on commit d16f832

Please sign in to comment.