Skip to content

Commit

Permalink
Adding small test
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>
  • Loading branch information
pedro-stanaka committed Mar 2, 2023
1 parent a0e7254 commit 6a6a3fd
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pkg/queryfrontend/split_by_interval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
package queryfrontend

import (
"encoding/json"
"strconv"
"testing"
"time"

"github.com/weaveworks/common/httpgrpc"

"github.com/stretchr/testify/require"
"github.com/thanos-io/thanos/internal/cortex/querier/queryrange"
)
Expand Down Expand Up @@ -238,3 +241,20 @@ func TestSplitQuery(t *testing.T) {
})
}
}

func TestSplitQuery_PromQLErrorReturnsJson(t *testing.T) {
input := &ThanosQueryRangeRequest{
Start: 2 * 3600 * seconds,
End: 3 * 3 * 3600 * seconds,
Step: 15 * seconds,
Query: "foo{",
}
queries, err := splitQuery(input, 1*time.Hour)
require.Error(t, err)
require.Nil(t, queries)

resp, ok := httpgrpc.HTTPResponseFromError(err)
require.True(t, ok, "could not assemble httpgrpc.HTTPResponse, is not status.Status")

require.True(t, json.Valid(resp.Body), "error message is not valid JSON: %s", resp.Body)
}

0 comments on commit 6a6a3fd

Please sign in to comment.