func (c *TestClient) Delete(url string) (*http.Response, error) {
	return c.performAction(http.MethodDelete, url, nil, nil)
}
Delete performs a Delete request against the Redfish service.
package common
import (
	"encoding/json"
	"fmt"
	"io"
	"io/ioutil"
	"net/http"
)
type TestAPICall struct {
	Action string
	URL string
	Payload string
	CustomHeaders map[string]string
}
type TestClient struct {
	calls []TestAPICall
	CustomReturnForActions map[string][]interface{}
}
func (c *TestClient) CapturedCalls() []TestAPICall {
	return c.calls
}
func (c *TestClient) actionCount(action string) int {
	var actionCount int
	for _, call := range c.calls {
		if call.Action == action {
			actionCount++
		}
	}
	return actionCount
}
func (c *TestClient) getCustomReturnForAction(action string) interface{} {
	switch action {
	case http.MethodGet, http.MethodPost,
		http.MethodPut, http.MethodPatch,
		http.MethodDelete:
		customReturnForAction, ok := c.CustomReturnForActions[action]
		if !ok ||
			customReturnForAction == nil ||
			customReturnForAction[c.actionCountIndex(action)] == nil {
			return nil
		}
		return customReturnForAction[c.actionCountIndex(action)]
	}
	return nil
}
func (c *TestClient) actionCountIndex(action string) int {
	return c.actionCount(action) - 1
}
func (c *TestClient) getPayloadToBeRecorded(payload interface{}) string {
	if payload != nil {
		payloadMarshaled, err := json.Marshal(payload)
		if err != nil {
			return fmt.Sprintf("%v", payload)
		}
		var payloadInterface interface{}
		err = json.Unmarshal(payloadMarshaled, &payloadInterface)
		if err != nil {
			return fmt.Sprintf("%v", payload)
		}
		return fmt.Sprintf("%v", payloadInterface)
	}
	return ""
}
func (c *TestClient) Reset() {
	c.calls = []TestAPICall{}
	c.CustomReturnForActions = map[string][]interface{}{}
}
func (c *TestClient) recordCall(action, url string, payload interface{}, customHeaders map[string]string) {
	call := TestAPICall{
		Action:        action,
		URL:           url,
		Payload:       c.getPayloadToBeRecorded(payload),
		CustomHeaders: customHeaders,
	}
	c.calls = append(c.calls, call)
}
func (c *TestClient) performAction(action, url string, payload interface{}, customHeaders map[string]string) (*http.Response, error) {
	c.recordCall(action, url, payload, customHeaders)
	customReturnForAction := c.getCustomReturnForAction(action)
	if customReturnForAction == nil {
		return nil, nil
	}
	resp := customReturnForAction.(*http.Response)
	if resp.StatusCode != 200 && resp.StatusCode != 201 && resp.StatusCode != 202 && resp.StatusCode != 204 {
		payload, err := ioutil.ReadAll(resp.Body)
		if err != nil {
			return nil, err
		}
		defer resp.Body.Close()
		return nil, ConstructError(resp.StatusCode, payload)
	}
	return resp, nil
}
func (c *TestClient) Get(url string) (*http.Response, error) {
	return c.performAction(http.MethodGet, url, nil, nil)
}
func (c *TestClient) GetWithHeaders(url string, customHeaders map[string]string) (*http.Response, error) {
	return c.performAction(http.MethodGet, url, nil, customHeaders)
}
func (c *TestClient) Post(url string, payload interface{}) (*http.Response, error) {
	return c.performAction(http.MethodPost, url, payload, nil)
}
func (c *TestClient) PostWithHeaders(url string, payload interface{}, customHeaders map[string]string) (*http.Response, error) {
	return c.performAction(http.MethodPost, url, payload, customHeaders)
}
func (c *TestClient) PostMultipart(url string, payload map[string]io.Reader) (*http.Response, error) {
	return c.performAction(http.MethodPost, url, payload, nil)
}
func (c *TestClient) PostMultipartWithHeaders(url string, payload map[string]io.Reader, customHeaders map[string]string) (*http.Response, error) {
	return c.performAction(http.MethodPost, url, payload, customHeaders)
}
func (c *TestClient) Put(url string, payload interface{}) (*http.Response, error) {
	return c.performAction(http.MethodPut, url, payload, nil)
}
func (c *TestClient) PutWithHeaders(url string, payload interface{}, customHeaders map[string]string) (*http.Response, error) {
	return c.performAction(http.MethodPut, url, payload, customHeaders)
}
func (c *TestClient) Patch(url string, payload interface{}) (*http.Response, error) {
	return c.performAction(http.MethodPatch, url, payload, nil)
}
func (c *TestClient) PatchWithHeaders(url string, payload interface{}, customHeaders map[string]string) (*http.Response, error) {
	return c.performAction(http.MethodPatch, url, payload, customHeaders)
}