formula_test.go
formula_test.go - Overview
This file contains unit tests for the formula processing logic in the postprocess
package. It tests the functionality of finding unique label sets and processing results based on mathematical expressions.
Detailed Documentation
TestFindUniqueLabelSets
Purpose:
Tests the findUniqueLabelSets
function to ensure it correctly identifies and returns unique label sets from a list of query results.
Parameters:
t
(*testing.T): Testing object for running the test case.
Returns:
None. The function asserts that the returned label sets match the expected label sets.
TestProcessResults
Purpose:
Tests the processResults
function, which evaluates expressions using query results and handles potential errors during parsing or processing.
Parameters:
t
(*testing.T): Testing object for running the test case.
Returns:
None. The function asserts that the processed results match the expected results, including the values of points in the time series.
TestProcessResultsErrorRate
Purpose:
Tests the processResults
function specifically for calculating error rates based on the provided query results.
Parameters:
t
(*testing.T): Testing object for running the test case.
Returns:
None. The function asserts that the processed results match the expected error rates.
TestFormula
Purpose:
Tests the end-to-end formula processing logic, including scenarios with different grouping keys and complex expressions.
Parameters:
t
(*testing.T): Testing object for running the test case.
Returns:
None. The function asserts that the results of the formula evaluation match the expected values.
TestProcessResultsNoDefaultZero
Purpose:
Tests the processResults
function when default zeroing is disabled for queries involved in the expression.
Parameters:
t
(*testing.T): Testing object for running the test case.
Returns:
None. The function asserts that the processed results match the expected results when default zeroing is disabled.
TestProcessResultsMixedQueries
Purpose:
Tests the processResults
function with a mix of different queries to ensure the formula processing works correctly in more complex scenarios.
Parameters:
t
(*testing.T): Testing object for running the test case.
Returns:
None. The function asserts that the processed results match the expected results for the mixed queries.
Include in Getting Started: NO