You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: segment_test.go
    path of file: ./repos/goa/http/middleware/xray
    
    the code of the file until where you have to start completion: package xray

import (
	"net"
	"net/http"
	"net/http/httptest"
	"net/url"
	"strings"
	"sync
    
func TestRecordResponse(t *testing.T) {
	type Res struct {
		Status int
		Body   string
	}

	cases := map[string]struct {
		Response Res
		Request  *xray.Request
	}{
		"with-HTTP.Request": {
			Response: Res{Status: http.StatusOK, Body: "hello"},
			Request:  &xray.Request{Method: "GET"},
		},
		"without-HTTP.Request": {
			Response: Res{Status: http.StatusOK, Body: "hello"},
			Request:  nil,
		},
	}

	for k, c := range cases {
		t.Run(k, func(t *testing.T) {
			rw := httptest.NewRecorder()
			rw.WriteHeader(c.Response.Status)
			if _, err := rw.WriteString(c.Response.Body); err != nil {
				t.Fatalf("failed to write response body - %s", err)
			}
			resp := rw.Result()
			// Fixed in go1.8 with commit
			// https://github.com/golang/go/commit/ea143c299040f8a270fb782c5efd3a3a5e6057a4
			// to stay backwards compatible with go1.7, we set ContentLength manually
			resp.ContentLength = int64(len(c.Response.Body))

			s := HTTPSegment{Segment: &xray.Segment{Mutex: &sync.Mutex{}}}
			if c.Request != nil {
				s.HTTP = &xray.HTTP{Request: c.Request}
			}

			s.RecordResponse(resp)

			if s.HTTP == nil {
				t.Fatal("HTTP field is nil")
			}
			if s.HTTP.Response == nil {
				t.Fatalf("HTTP Response field is nil")
			}
			if s.HTTP.Response.Status != c.Response.Status {
				t.Errorf("HTTP Response Status is invalid, expected %d got %d", c.Response.Status, s.HTTP.Response.Status)
			}
			if s.HTTP.Response.ContentLength != int64(len(c.Response.Body)) {
				t.Errorf("HTTP Response ContentLength is invalid, expected %d got %d", len(c.Response.Body), s.HTTP.Response.ContentLength)
			}
		})
	}
}