@@ -19,39 +19,39 @@ func TestQueryData_parseResponse(t *testing.T) {
1919 t .Run ("resultType is before result the field must parsed normally" , func (t * testing.T ) {
2020 resBody := `{"data":{"resultType":"vector", "result":[{"metric":{"__name__":"some_name","environment":"some_env","id":"some_id","instance":"some_instance:1234","job":"some_job","name":"another_name","region":"some_region"},"value":[1.1,"2"]}]},"status":"success"}`
2121 res := & http.Response {Body : io .NopCloser (bytes .NewBufferString (resBody ))}
22- result := qd .parseResponse (context .Background (), & models.Query {}, res , false )
22+ result := qd .parseResponse (context .Background (), & models.Query {}, res )
2323 assert .Nil (t , result .Error )
2424 assert .Len (t , result .Frames , 1 )
2525 })
2626
2727 t .Run ("resultType is after the result field must parsed normally" , func (t * testing.T ) {
2828 resBody := `{"data":{"result":[{"metric":{"__name__":"some_name","environment":"some_env","id":"some_id","instance":"some_instance:1234","job":"some_job","name":"another_name","region":"some_region"},"value":[1.1,"2"]}],"resultType":"vector"},"status":"success"}`
2929 res := & http.Response {Body : io .NopCloser (bytes .NewBufferString (resBody ))}
30- result := qd .parseResponse (context .Background (), & models.Query {}, res , false )
30+ result := qd .parseResponse (context .Background (), & models.Query {}, res )
3131 assert .Nil (t , result .Error )
3232 assert .Len (t , result .Frames , 1 )
3333 })
3434
3535 t .Run ("no resultType is existed in the data" , func (t * testing.T ) {
3636 resBody := `{"data":{"result":[{"metric":{"__name__":"some_name","environment":"some_env","id":"some_id","instance":"some_instance:1234","job":"some_job","name":"another_name","region":"some_region"},"value":[1.1,"2"]}]},"status":"success"}`
3737 res := & http.Response {Body : io .NopCloser (bytes .NewBufferString (resBody ))}
38- result := qd .parseResponse (context .Background (), & models.Query {}, res , false )
38+ result := qd .parseResponse (context .Background (), & models.Query {}, res )
3939 assert .Error (t , result .Error )
4040 assert .Equal (t , result .Error .Error (), "no resultType found" )
4141 })
4242
4343 t .Run ("resultType is set as empty string before result" , func (t * testing.T ) {
4444 resBody := `{"data":{"resultType":"", "result":[{"metric":{"__name__":"some_name","environment":"some_env","id":"some_id","instance":"some_instance:1234","job":"some_job","name":"another_name","region":"some_region"},"value":[1.1,"2"]}]},"status":"success"}`
4545 res := & http.Response {Body : io .NopCloser (bytes .NewBufferString (resBody ))}
46- result := qd .parseResponse (context .Background (), & models.Query {}, res , false )
46+ result := qd .parseResponse (context .Background (), & models.Query {}, res )
4747 assert .Error (t , result .Error )
4848 assert .Equal (t , result .Error .Error (), "unknown result type: " )
4949 })
5050
5151 t .Run ("resultType is set as empty string after result" , func (t * testing.T ) {
5252 resBody := `{"data":{"result":[{"metric":{"__name__":"some_name","environment":"some_env","id":"some_id","instance":"some_instance:1234","job":"some_job","name":"another_name","region":"some_region"},"value":[1.1,"2"]}],"resultType":""},"status":"success"}`
5353 res := & http.Response {Body : io .NopCloser (bytes .NewBufferString (resBody ))}
54- result := qd .parseResponse (context .Background (), & models.Query {}, res , false )
54+ result := qd .parseResponse (context .Background (), & models.Query {}, res )
5555 assert .Error (t , result .Error )
5656 assert .Equal (t , result .Error .Error (), "unknown result type: " )
5757 })
0 commit comments