summaryrefslogtreecommitdiffstats
path: root/vendor/gopkg.in/olivere/elastic.v5/bulk_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/gopkg.in/olivere/elastic.v5/bulk_test.go')
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/bulk_test.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/vendor/gopkg.in/olivere/elastic.v5/bulk_test.go b/vendor/gopkg.in/olivere/elastic.v5/bulk_test.go
index fba52be73..394439630 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/bulk_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/bulk_test.go
@@ -7,6 +7,9 @@ package elastic
import (
"context"
"encoding/json"
+ "fmt"
+ "net/http"
+ "net/http/httptest"
"testing"
)
@@ -505,3 +508,27 @@ func BenchmarkBulkEstimatedSizeInBytesWith100Requests(b *testing.B) {
b.ReportAllocs()
benchmarkBulkEstimatedSizeInBytes = result // ensure the compiler doesn't optimize
}
+
+func TestBulkContentType(t *testing.T) {
+ var header http.Header
+ ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ header = r.Header
+ fmt.Fprintln(w, `{}`)
+ }))
+ defer ts.Close()
+
+ client, err := NewSimpleClient(SetURL(ts.URL))
+ if err != nil {
+ t.Fatal(err)
+ }
+ indexReq := NewBulkIndexRequest().Index(testIndexName).Type("tweet").Id("1").Doc(tweet{User: "olivere", Message: "Welcome to Golang and Elasticsearch."})
+ if _, err := client.Bulk().Add(indexReq).Do(context.Background()); err != nil {
+ t.Fatal(err)
+ }
+ if header == nil {
+ t.Fatalf("expected header, got %v", header)
+ }
+ if want, have := "application/x-ndjson", header.Get("Content-Type"); want != have {
+ t.Fatalf("Content-Type: want %q, have %q", want, have)
+ }
+}