mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-14 01:25:53 +08:00
Add error check in unit tests. (#1993)
This commit is contained in:
parent
6cd341a887
commit
f7ff491d35
@ -102,8 +102,8 @@ var correctQueriesTest = []struct {
|
|||||||
func TestParseLogQueryCorrect(t *testing.T) {
|
func TestParseLogQueryCorrect(t *testing.T) {
|
||||||
for _, test := range correctQueriesTest {
|
for _, test := range correctQueriesTest {
|
||||||
Convey(test.Name, t, func() {
|
Convey(test.Name, t, func() {
|
||||||
query, _ := parseLogQuery(test.InputQuery)
|
query, err := parseLogQuery(test.InputQuery)
|
||||||
|
So(err, ShouldBeNil)
|
||||||
So(query, ShouldResemble, test.WantSqlTokens)
|
So(query, ShouldResemble, test.WantSqlTokens)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -206,7 +206,8 @@ var parseCorrectColumns = []struct {
|
|||||||
func TestParseColumn(t *testing.T) {
|
func TestParseColumn(t *testing.T) {
|
||||||
for _, test := range parseCorrectColumns {
|
for _, test := range parseCorrectColumns {
|
||||||
Convey(test.Name, t, func() {
|
Convey(test.Name, t, func() {
|
||||||
column, _ := parseColumn(test.Filter)
|
column, err := parseColumn(test.Filter)
|
||||||
|
So(err, ShouldBeNil)
|
||||||
So(*column, ShouldEqual, test.Column)
|
So(*column, ShouldEqual, test.Column)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -216,14 +217,14 @@ func TestReplaceInterestingFields(t *testing.T) {
|
|||||||
queryTokens := []string{"id.userid IN (100) ", "and id_key >= 50 ", `AND body ILIKE '%searchstring%'`}
|
queryTokens := []string{"id.userid IN (100) ", "and id_key >= 50 ", `AND body ILIKE '%searchstring%'`}
|
||||||
allFields := model.GetFieldsResponse{
|
allFields := model.GetFieldsResponse{
|
||||||
Selected: []model.LogField{
|
Selected: []model.LogField{
|
||||||
model.LogField{
|
{
|
||||||
Name: "id_key",
|
Name: "id_key",
|
||||||
DataType: "int64",
|
DataType: "int64",
|
||||||
Type: "attributes",
|
Type: "attributes",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Interesting: []model.LogField{
|
Interesting: []model.LogField{
|
||||||
model.LogField{
|
{
|
||||||
Name: "id.userid",
|
Name: "id.userid",
|
||||||
DataType: "int64",
|
DataType: "int64",
|
||||||
Type: "attributes",
|
Type: "attributes",
|
||||||
@ -233,7 +234,8 @@ func TestReplaceInterestingFields(t *testing.T) {
|
|||||||
|
|
||||||
expectedTokens := []string{"attributes_int64_value[indexOf(attributes_int64_key, 'id.userid')] IN (100) ", "and id_key >= 50 ", `AND body ILIKE '%searchstring%'`}
|
expectedTokens := []string{"attributes_int64_value[indexOf(attributes_int64_key, 'id.userid')] IN (100) ", "and id_key >= 50 ", `AND body ILIKE '%searchstring%'`}
|
||||||
Convey("testInterestingFields", t, func() {
|
Convey("testInterestingFields", t, func() {
|
||||||
tokens, _ := replaceInterestingFields(&allFields, queryTokens)
|
tokens, err := replaceInterestingFields(&allFields, queryTokens)
|
||||||
|
So(err, ShouldBeNil)
|
||||||
So(tokens, ShouldResemble, expectedTokens)
|
So(tokens, ShouldResemble, expectedTokens)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -372,7 +374,8 @@ var generateSQLQueryTestCases = []struct {
|
|||||||
func TestGenerateSQLQuery(t *testing.T) {
|
func TestGenerateSQLQuery(t *testing.T) {
|
||||||
for _, test := range generateSQLQueryTestCases {
|
for _, test := range generateSQLQueryTestCases {
|
||||||
Convey("testGenerateSQL", t, func() {
|
Convey("testGenerateSQL", t, func() {
|
||||||
res, _, _ := GenerateSQLWhere(&generateSQLQueryFields, &test.Filter)
|
res, _, err := GenerateSQLWhere(&generateSQLQueryFields, &test.Filter)
|
||||||
|
So(err, ShouldBeNil)
|
||||||
So(res, ShouldEqual, test.SqlFilter)
|
So(res, ShouldEqual, test.SqlFilter)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user