2021-05-19 16:53:41 -05:00
|
|
|
package httpclientprovider
|
|
|
|
|
|
|
|
import (
|
2022-07-21 08:46:47 -05:00
|
|
|
"bytes"
|
2022-08-10 08:37:51 -05:00
|
|
|
"io"
|
2021-05-19 16:53:41 -05:00
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/grafana/grafana-plugin-sdk-go/backend/httpclient"
|
|
|
|
)
|
|
|
|
|
|
|
|
type testContext struct {
|
|
|
|
callChain []string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *testContext) createRoundTripper(name string) http.RoundTripper {
|
|
|
|
return httpclient.RoundTripperFunc(func(req *http.Request) (*http.Response, error) {
|
|
|
|
c.callChain = append(c.callChain, name)
|
2022-07-21 08:46:47 -05:00
|
|
|
return &http.Response{
|
|
|
|
StatusCode: http.StatusOK,
|
|
|
|
Request: req,
|
2022-08-10 08:37:51 -05:00
|
|
|
Body: io.NopCloser(bytes.NewBufferString("")),
|
2022-07-21 08:46:47 -05:00
|
|
|
}, nil
|
2021-05-19 16:53:41 -05:00
|
|
|
})
|
|
|
|
}
|