Files
kubesphere/pkg/simple/client/kiali/mock_client.go
Eng Zer Jun d1fec72a32 refactor: move from io/ioutil to io and os packages (#5266)
The io/ioutil package has been deprecated as of Go 1.16 [1]. This commit
replaces the existing io/ioutil functions with their new definitions in
io and os packages.

[1]: https://golang.org/doc/go1.16#ioutil
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-10-18 15:47:38 +08:00

28 lines
537 B
Go

package kiali
import (
"bytes"
"io"
"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: io.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: io.NopCloser(bytes.NewReader(c.TokenResult)),
}, nil
}