logs-analyzer/signoz/pkg/query-service/app/clickhouseReader/reader_test.go

30 lines
933 B
Go
Raw Normal View History

2024-09-02 22:47:30 +03:00
package clickhouseReader
import (
"testing"
"github.com/stretchr/testify/assert"
)
type GetStatusFiltersTest struct {
query string
statusParams []string
excludeMap map[string]struct{}
expected string
}
func TestGetStatusFilters(t *testing.T) {
assert := assert.New(t)
var tests = []GetStatusFiltersTest{
{"", make([]string, 0), map[string]struct{}{}, ""},
{"test", []string{"error"}, map[string]struct{}{}, "test AND hasError = true"},
{"test", []string{"ok"}, map[string]struct{}{}, "test AND hasError = false"},
{"test", []string{"error"}, map[string]struct{}{"status": {}}, "test AND hasError = false"},
{"test", []string{"ok"}, map[string]struct{}{"status": {}}, "test AND hasError = true"},
{"test", []string{"error", "ok"}, map[string]struct{}{}, "test"},
}
for _, test := range tests {
assert.Equal(getStatusFilters(test.query, test.statusParams, test.excludeMap), test.expected)
}
}