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>
28 lines
537 B
Go
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
|
|
}
|