mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
tests: API: Use jsoniter when encoding
So that tests use the same encoding as the api. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
parent
2c4a36376d
commit
5a339ba359
|
@ -15,7 +15,6 @@ package v1
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
|
@ -35,6 +34,7 @@ import (
|
|||
"github.com/prometheus/prometheus/util/testutil"
|
||||
|
||||
"github.com/go-kit/log"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
config_util "github.com/prometheus/common/config"
|
||||
"github.com/prometheus/common/model"
|
||||
|
@ -910,6 +910,7 @@ func TestStats(t *testing.T) {
|
|||
require.IsType(t, &QueryData{}, i)
|
||||
qd := i.(*QueryData)
|
||||
require.NotNil(t, qd.Stats)
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
j, err := json.Marshal(qd.Stats)
|
||||
require.NoError(t, err)
|
||||
require.JSONEq(t, `{"custom":"Custom Value"}`, string(j))
|
||||
|
@ -2895,6 +2896,7 @@ func testEndpoints(t *testing.T, api *API, tr *testTargetRetriever, es storage.E
|
|||
}
|
||||
|
||||
if test.responseAsJSON != "" {
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
s, err := json.Marshal(res.data)
|
||||
require.NoError(t, err)
|
||||
require.JSONEq(t, test.responseAsJSON, string(s))
|
||||
|
|
Loading…
Reference in a new issue