Skip to content

Commit

Permalink
Quickfix incorrect tests (#290)
Browse files Browse the repository at this point in the history
It's a bit concerning that these tests passed most of the time, even
though we expected 1 query in mock, but actually sent 2.
Maybe it's introduced by this newly added
`mock.MatchExpectationsInOrder(false)`? Maybe sqlmock's bug? Maybe my
bug?
I'll try to inspect that for a bit, but it seems to solve the flakiness
+ results should **now** be correct
  • Loading branch information
trzysiek authored and pdelewski committed Jun 9, 2024
1 parent 83bcce4 commit 50c6eac
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
2 changes: 0 additions & 2 deletions quesma/queryparser/query_translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package queryparser

import (
"context"
"fmt"
"mitmproxy/quesma/clickhouse"
"mitmproxy/quesma/kibana"
"mitmproxy/quesma/logger"
Expand Down Expand Up @@ -224,7 +223,6 @@ func (cw *ClickhouseQueryTranslator) MakeAggregationPartOfResponse(queries []*mo
if i >= len(ResultSets) || query_util.IsNonAggregationQuery(query) {
continue
}
fmt.Println(i, query.Type, query)
aggregation := cw.makeResponseAggregationRecursive(query, ResultSets[i], 0, 0)
if len(aggregation) != 0 {
aggregations = util.MergeMaps(cw.Ctx, aggregations, aggregation[0]) // result of root node is always a single map, thus [0]
Expand Down
20 changes: 16 additions & 4 deletions quesma/testdata/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,10 @@ var TestsSearch = []SearchTestCase{
[]string{""},
model.ListAllFields,
//[]model.Query{newSimplestQuery()},
[]string{`SELECT "message" FROM ` + QuotedTableName},
[]string{
`SELECT count() FROM ` + QuotedTableName,
`SELECT "message" FROM ` + QuotedTableName,
},
},
{ // [16]
"Simplest 'match_phrase'",
Expand Down Expand Up @@ -1931,7 +1934,10 @@ var TestsSearch = []SearchTestCase{
[]string{""},
model.ListByField,
//[]model.Query{withLimit(newSimplestQuery(), 500)},
[]string{`SELECT "message" FROM ` + QuotedTableName + ` LIMIT 500`},
[]string{
`SELECT count() FROM ` + QuotedTableName,
`SELECT "message" FROM ` + QuotedTableName + ` LIMIT 500`,
},
},
{ // [26]
"Empty must",
Expand Down Expand Up @@ -2001,7 +2007,10 @@ var TestsSearch = []SearchTestCase{
[]string{``},
model.ListAllFields,
//[]model.Query{justSimplestWhere(``)},
[]string{`SELECT "message" FROM ` + QuotedTableName},
[]string{
`SELECT count() FROM ` + QuotedTableName,
`SELECT "message" FROM ` + QuotedTableName,
},
},
{ // [30]
"Some bools empty, some not",
Expand Down Expand Up @@ -2043,7 +2052,10 @@ var TestsSearch = []SearchTestCase{
[]string{""},
model.ListAllFields,
//[]model.Query{newSimplestQuery()},
[]string{`SELECT "message" FROM ` + QuotedTableName},
[]string{
`SELECT count() FROM ` + QuotedTableName,
`SELECT "message" FROM ` + QuotedTableName,
},
},
{ // [32]
"Constant score query",
Expand Down

0 comments on commit 50c6eac

Please sign in to comment.