add unit test for GetServiceTracing

This commit is contained in:
zhanghaiwen
2022-06-02 14:46:27 +08:00
parent 04d70b1db4
commit 02e99365c7
4 changed files with 188 additions and 25 deletions

View File

@@ -0,0 +1,27 @@
package kiali
import (
"bytes"
"io/ioutil"
"net/http"
"net/url"
)
type MockClient struct {
TokenResult []byte
RequestResult string
}
func (c *MockClient) Do(req *http.Request) (*http.Response, error) {
return &http.Response{
StatusCode: 200,
Body: ioutil.NopCloser(bytes.NewReader([]byte(c.RequestResult))),
}, nil
}
func (c *MockClient) PostForm(url string, data url.Values) (resp *http.Response, err error) {
return &http.Response{
StatusCode: 200,
Body: ioutil.NopCloser(bytes.NewReader(c.TokenResult)),
}, nil
}