Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

Add error check in unit tests. (#1993)

Axay Sagathiyaf7ff491d350f
diff --git a/pkg/query-service/app/logs/parser_test.go b/pkg/query-service/app/logs/parser_test.go
index b139038b8f..f11419e30f 100644
--- a/pkg/query-service/app/logs/parser_test.go
+++ b/pkg/query-service/app/logs/parser_test.go
@@ -102,8 +102,8 @@ var correctQueriesTest = []struct {
func TestParseLogQueryCorrect(t *testing.T) {
for _, test := range correctQueriesTest {
Convey(test.Name, t, func() {
- query, _ := parseLogQuery(test.InputQuery)
-
+ query, err := parseLogQuery(test.InputQuery)
+ So(err, ShouldBeNil)
So(query, ShouldResemble, test.WantSqlTokens)
})
}
@@ -206,7 +206,8 @@ var parseCorrectColumns = []struct {
func TestParseColumn(t *testing.T) {
for _, test := range parseCorrectColumns {
Convey(test.Name, t, func() {
- column, _ := parseColumn(test.Filter)
+ column, err := parseColumn(test.Filter)
+ So(err, ShouldBeNil)
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%'`}
allFields := model.GetFieldsResponse{
Selected: []model.LogField{
- model.LogField{
+ {
Name: "id_key",
DataType: "int64",
Type: "attributes",
},
},
Interesting: []model.LogField{
- model.LogField{
+ {
Name: "id.userid",
DataType: "int64",
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%'`}
Convey("testInterestingFields", t, func() {
- tokens, _ := replaceInterestingFields(&allFields, queryTokens)
+ tokens, err := replaceInterestingFields(&allFields, queryTokens)
+ So(err, ShouldBeNil)
So(tokens, ShouldResemble, expectedTokens)
})
}
@@ -372,7 +374,8 @@ var generateSQLQueryTestCases = []struct {
func TestGenerateSQLQuery(t *testing.T) {
for _, test := range generateSQLQueryTestCases {
Convey("testGenerateSQL", t, func() {
- res, _, _ := GenerateSQLWhere(&generateSQLQueryFields, &test.Filter)
+ res, _, err := GenerateSQLWhere(&generateSQLQueryFields, &test.Filter)
+ So(err, ShouldBeNil)
So(res, ShouldEqual, test.SqlFilter)
})
}