func assertHttpMatchRecorder(t *testing.T, recorder *httptest.ResponseRecorder,
	expectedStatus int, expectedHeaders http.Header, expectedBody string) {
	assert.Equal(t, expectedStatus, recorder.Code)
	assert.Equal(t, recorder.Header(), expectedHeaders)
	assert.Equal(t, expectedBody, recorder.Body.String())
}
Test that the headers and body match.
package server
import (
	"bytes"
	"fmt"
	"github.com/stretchr/testify/assert"
	"io/ioutil"
	"log"
	"net/http"
	"net/http/httptest"
	"testing"
)
func buildApiRequest(url, body string, httpHeaders http.Header) *apiRequest {
	req := buildRequest(url, body, httpHeaders)
	apiRequest, err := newApiRequest(req)
	if err != nil {
		log.Fatal(err.Error())
	}
	return apiRequest
}
func buildRequest(url, body string, httpHeaders http.Header) *http.Request {
	req, err := http.NewRequest("GET", fmt.Sprintf("http://localhost:42%s", url),
		ioutil.NopCloser(bytes.NewBufferString(body)))
	if err != nil {
		log.Fatal(err.Error())
	}
	req.Header.Set("Content-Type", "application/json")
	if httpHeaders != nil {
		for key, value := range httpHeaders {
			req.Header.Set(key, value[0])
		}
	}
	return req
}
func assertHttpMatch(t *testing.T, response *http.Response, expectedStatus int,
	expectedHeaders http.Header, expectedBody string) {
	assert.Equal(t, expectedStatus, response.StatusCode)
	assert.Equal(t, response.Header, expectedHeaders)
	body, _ := ioutil.ReadAll(response.Body)
	assert.Equal(t, expectedBody, string(body))
}