Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type HttpClient interface {
- Do(req *http.Request) (*http.Response, error)
- }
- func GetOverview(client HttpClient, overview *Overview) (*Overview, error) {
- request, err := http.NewRequest("GET", fmt.Sprintf("%s:%s/api/overview", overview.Config.Url, overview.Config.Port), nil)
- if (err != nil) {
- log.Println(err)
- }
- request.SetBasicAuth(overview.Config.User, overview.Config.Password)
- resp, err := client.Do(request)
- type ClientMock struct {
- }
- func (c *ClientMock) Do(req *http.Request) (*http.Response, error) {
- return &http.Response{}, nil
- }
- type HttpClient interface {
- Do(req *http.Request) (*http.Response, error)
- }
- type MockClient struct {
- DoFunc func(req *http.Request) (*http.Response, error)
- }
- func (m *MockClient) Do(req *http.Request) (*http.Response, error) {
- if m.DoFunc != nil {
- return m.DoFunc(req)
- }
- return &http.Response{}, nil
- }
Add Comment
Please, Sign In to add comment