func EncodeJSON(data interface{}) ([]byte, error) {
	if data == nil {
		return []byte{}, nil
	}
	b, err := json.Marshal(data)
	if err != nil {
		return []byte{}, errors.Wrap(err, "Error while encoding json")
	}
	return b, nil
}
EncodeJSON encodes json data in bytes
package testutils
import (
	"bytes"
	"encoding/json"
	"io"
	"net/http"
	"net/http/httptest"
	"testing"
	"github.com/pkg/errors"
	"github.com/stretchr/testify/assert"
)
const (
	ContentTypeJSON contentType = "application/json"
	ContentTypeHTML contentType = "text/html"
	ContentTypePlain contentType = "text/plain; charset=utf-8"
)
type contentType string
type Request struct {
	Method string
	URL    string
	Header http.Header
	Body   interface{}
}
type ExpectedResponse struct {
	StatusCode   int
	ResponseType contentType
	Body         interface{}
}
type HTTPTest struct {
	*testing.T
	Encoder func(interface{}) ([]byte, error)
}