mirror of
https://github.com/hanzoai/traces.git
synced 2026-10-30 18:20:41 +00:00
* dedicated columns tracker thing Signed-off-by: Joe Elliott <[email protected]> * update traceql search Signed-off-by: Joe Elliott <[email protected]> * query range Signed-off-by: Joe Elliott <[email protected]> * Add query builder test Signed-off-by: Joe Elliott <[email protected]> * changelog Signed-off-by: Joe Elliott <[email protected]> * fix cli Signed-off-by: Joe Elliott <[email protected]> * lint Signed-off-by: Joe Elliott <[email protected]> * lint and review Signed-off-by: Joe Elliott <[email protected]> * wups Signed-off-by: Joe Elliott <[email protected]> --------- Signed-off-by: Joe Elliott <[email protected]>
39 lines
815 B
Go
39 lines
815 B
Go
package api
|
|
|
|
import (
|
|
"math/rand/v2"
|
|
"net/url"
|
|
"testing"
|
|
|
|
"github.com/grafana/tempo/pkg/util/test"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestQueryBuilder(t *testing.T) {
|
|
numParams := rand.IntN(10) + 1
|
|
|
|
qb := newQueryBuilder("")
|
|
params := url.Values{}
|
|
|
|
for i := 0; i < numParams; i++ {
|
|
key := test.RandomString()
|
|
value := test.RandomString()
|
|
|
|
qb.addParam(key, value)
|
|
params.Add(key, value)
|
|
}
|
|
|
|
// url sorts params but query builder does not. parse the query builder
|
|
// string with url to guarantee its valid and also to sort the params
|
|
actualQuery, err := url.ParseQuery(qb.query())
|
|
require.NoError(t, err)
|
|
|
|
actual := url.URL{}
|
|
actual.RawQuery = actualQuery.Encode()
|
|
|
|
expected := url.URL{}
|
|
expected.RawQuery = params.Encode()
|
|
|
|
require.Equal(t, expected.RawQuery, actual.RawQuery)
|
|
}
|