Skip to content

Commit 4de34f1

Browse files
committed
chore: bump gojq
1 parent bb329be commit 4de34f1

4 files changed

Lines changed: 54 additions & 5 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ toolchain go1.23.2
66

77
require (
88
github.com/google/gnostic-models v0.6.9
9-
github.com/itchyny/gojq v0.12.15
9+
github.com/itchyny/gojq v0.12.17
1010
github.com/pkg/errors v0.9.1
1111
github.com/stretchr/testify v1.10.0
1212
gopkg.in/yaml.v3 v3.0.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
6363
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
6464
github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI=
6565
github.com/huandu/xstrings v1.5.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
66-
github.com/itchyny/gojq v0.12.15 h1:WC1Nxbx4Ifw5U2oQWACYz32JK8G9qxNtHzrvW4KEcqI=
67-
github.com/itchyny/gojq v0.12.15/go.mod h1:uWAHCbCIla1jiNxmeT5/B5mOjSdfkCq6p8vxWg+BM10=
66+
github.com/itchyny/gojq v0.12.17 h1:8av8eGduDb5+rvEdaOO+zQUjA04MS0m3Ps8HiD+fceg=
67+
github.com/itchyny/gojq v0.12.17/go.mod h1:WBrEMkgAfAGO1LUcGOckBl5O726KPp+OlkKug0I/FEY=
6868
github.com/itchyny/timefmt-go v0.1.6 h1:ia3s54iciXDdzWzwaVKXZPbiXzxxnv1SPGFfM/myJ5Q=
6969
github.com/itchyny/timefmt-go v0.1.6/go.mod h1:RRDZYC5s9ErkjQvTvvU7keJjxUYzIISJGxm9/mAERQg=
7070
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=

internal/parser/parser.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func ParseExpectations(spec string, sctx SourceContext) ([]*ParsedQuery, error)
4141
next = line
4242
}
4343

44-
if current != "" {
44+
if current != "" && !strings.HasPrefix(current, "#") {
4545
query, err := ParseQuery(current, currentSCtx)
4646
if err != nil {
4747
return nil, errors.Wrapf(err, "parsing query ending at %s", sctx)
@@ -55,7 +55,7 @@ func ParseExpectations(spec string, sctx SourceContext) ([]*ParsedQuery, error)
5555
return nil, errors.Wrap(err, "parsing expectations")
5656
}
5757

58-
if current != "" {
58+
if current != "" && !strings.HasPrefix(current, "#") {
5959
query, err := ParseQuery(current, currentSCtx)
6060
if err != nil {
6161
return nil, errors.Wrapf(err, "parsing query ending at %s", sctx)

internal/parser/parser_test.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package parser
2+
3+
import (
4+
"github.com/stretchr/testify/assert"
5+
"testing"
6+
)
7+
8+
func TestParseExpectations(t *testing.T) {
9+
tests := map[string]struct {
10+
spec string
11+
want []string
12+
errFunc assert.ErrorAssertionFunc
13+
}{
14+
"empty": {spec: "", want: nil, errFunc: assert.NoError},
15+
"one query": {
16+
spec: "foo | bar",
17+
want: []string{"foo | bar"},
18+
errFunc: assert.NoError,
19+
},
20+
"a couple of queries with comments": {
21+
spec: `# a comment
22+
query1 | very |
23+
long
24+
# comment in between
25+
query2 | even |
26+
longer
27+
# trailing comment`,
28+
want: []string{
29+
"query1 | very | long",
30+
"query2 | even | longer",
31+
},
32+
errFunc: assert.NoError,
33+
},
34+
}
35+
for name, tt := range tests {
36+
t.Run(name, func(t *testing.T) {
37+
sourceCtx := SourceContext{
38+
Filename: name,
39+
Line: 1,
40+
}
41+
got, err := ParseExpectations(tt.spec, sourceCtx)
42+
tt.errFunc(t, err)
43+
assert.Len(t, got, len(tt.want))
44+
for i, query := range got {
45+
assert.Equal(t, tt.want[i], query.Source, "source of query %d should match", i)
46+
}
47+
})
48+
}
49+
}

0 commit comments

Comments
 (0)