1// Copyright 2012-present Oliver Eilhard. All rights reserved.
2// Use of this source code is governed by a MIT-license.
3// See http://olivere.mit-license.org/license.txt for details.
4
5package elastic
6
7import (
8	"bytes"
9	"fmt"
10	"io/ioutil"
11	"net/http"
12	"testing"
13)
14
15func BenchmarkResponse(b *testing.B) {
16	c := &Client{
17		decoder: &DefaultDecoder{},
18	}
19
20	var resp *Response
21	for n := 0; n < b.N; n++ {
22		iteration := fmt.Sprint(n)
23		body := fmt.Sprintf(`{"n":%d}`, n)
24		res := &http.Response{
25			Header: http.Header{
26				"X-Iteration": []string{iteration},
27			},
28			Body:       ioutil.NopCloser(bytes.NewBufferString(body)),
29			StatusCode: http.StatusOK,
30		}
31		var err error
32		resp, err = c.newResponse(res)
33		if err != nil {
34			b.Fatal(err)
35		}
36		/*
37			if want, have := body, string(resp.Body); want != have {
38				b.Fatalf("want %q, have %q", want, have)
39			}
40			//*/
41		/*
42			if want, have := iteration, resp.Header.Get("X-Iteration"); want != have {
43				b.Fatalf("want %q, have %q", want, have)
44			}
45			//*/
46	}
47	_ = resp
48}
49