query_builder_test.go
File Name: query_builder_test.go - Overview
-
Overview This file contains unit tests for the logs query builder, specifically focusing on the v3 version of the query model. It tests functions that generate ClickHouse column names, select labels, and build filter queries for logs.
-
Detailed Documentation
testGetClickhouseColumnNameData
- Purpose: Defines a test dataset for
getClickhouseColumnName
function. - Type:
[]struct
Name
:string
- Test case name.AttributeKey
:v3.AttributeKey
- Input attribute key.ExpectedColumnName
:string
- Expected ClickHouse column name.
TestGetClickhouseColumnName
- Purpose: Tests the
getClickhouseColumnName
function with various attribute key types. - Parameters:
t
:*testing.T
- Testing object.
- Returns: None
testGetSelectLabelsData
- Purpose: Defines a test dataset for the
getSelectLabels
function. - Type:
[]struct
Name
:string
- Test case name.AggregateOperator
:v3.AggregateOperator
- Aggregate operator.GroupByTags
:[]v3.AttributeKey
- Group by tags.SelectLabels
:string
- Expected select labels.
TestGetSelectLabels
- Purpose: Tests the
getSelectLabels
function with different aggregate operators and group by tags. - Parameters:
t
:*testing.T
- Testing object.
- Returns: None
timeSeriesFilterQueryData
- Purpose: Defines a test dataset for the
buildLogsTimeSeriesFilterQuery
function. - Type:
[]struct
Name
:string
- Test case name.FilterSet
:*v3.FilterSet
- Input filter set.GroupBy
:[]v3.AttributeKey
- Group by attribute keys.ExpectedFilter
:string
- Expected filter query.Fields
:map[string]v3.AttributeKey
- Attribute key map.Error
:string
- Expected error message.
TestBuildLogsTimeSeriesFilterQuery
- Purpose: Tests the
buildLogsTimeSeriesFilterQuery
function with various filter sets and group by configurations. - Parameters:
t
:*testing.T
- Testing object.
- Returns: None
testBuildLogsQueryData
- Purpose: Defines a test dataset for the
buildLogsQuery
function. - Type:
[]struct
Name
:string
- Test case name.PanelType
:v3.PanelType
- Panel type.Start
:int64
- Start timestamp.End
:int64
- End timestamp.Step
:int64
- Step interval.BuilderQuery
:*v3.BuilderQuery
- Builder query object.GroupByTags
:[]v3.AttributeKey
- Group by tags.TableName
:string
- Table name.AggregateOperator
:v3.AggregateOperator
- Aggregate operator.ExpectedQuery
:string
- Expected query string.Type
:int
- Type identifier.
TestBuildLogsQuery
- Purpose: Tests the
buildLogsQuery
function with various parameters. - Parameters:
t
:*testing.T
- Testing object.
- Returns: None
testOrderBy
- Purpose: Defines a test dataset for the
orderByAttributeKeyTags
function. - Type:
[]struct
Name
:string
- Test case name.PanelType
:v3.PanelType
- Panel type.Items
:[]v3.OrderBy
- Order by items.Tags
:[]v3.AttributeKey
- Attribute keys.Result
:string
- Expected result.
TestOrderBy
- Purpose: Tests the
orderByAttributeKeyTags
function. - Parameters:
t
:*testing.T
- Testing object.
- Returns: None
testPrepLogsQueryData
- Purpose: Defines a test dataset for the
PrepareLogsQuery
function. - Type:
[]struct
Name
:string
- Test case name.PanelType
:v3.PanelType
- Panel type.Start
:int64
- Start timestamp.End
:int64
- End timestamp.Step
:int64
- Step interval.BuilderQuery
:*v3.BuilderQuery
- Builder query object.GroupByTags
:[]v3.AttributeKey
- Group by tags.TableName
:string
- Table name.AggregateOperator
:v3.AggregateOperator
- Aggregate operator.ExpectedQuery
:string
- Expected query string.Options
:v3.QBOptions
- Query builder options.
TestPrepareLogsQuery
- Purpose: Tests the
PrepareLogsQuery
function with various parameters. - Parameters:
t
:*testing.T
- Testing object.
- Returns: None
testPrepLogsQueryLimitOffsetData
- Purpose: Defines a test dataset for the
PrepareLogsQuery
function focusing on limit and offset. - Type:
[]struct
Name
:string
- Test case name.PanelType
:v3.PanelType
- Panel type.Start
:int64
- Start timestamp.End
:int64
- End timestamp.Step
:int64
- Step interval.BuilderQuery
:*v3.BuilderQuery
- Builder query object.GroupByTags
:[]v3.AttributeKey
- Group by tags.TableName
:string
- Table name.AggregateOperator
:v3.AggregateOperator
- Aggregate operator.ExpectedQuery
:string
- Expected query string.Options
:v3.QBOptions
- Query builder options.
TestPrepareLogsQueryLimitOffset
- Purpose: Tests the
PrepareLogsQuery
function with various limit and offset parameters. - Parameters:
t
:*testing.T
- Testing object.
- Returns: None
Include in Getting Started: NO