summaryrefslogtreecommitdiffstats
path: root/vendor/gopkg.in/olivere/elastic.v5/client_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/gopkg.in/olivere/elastic.v5/client_test.go')
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/client_test.go64
1 files changed, 52 insertions, 12 deletions
diff --git a/vendor/gopkg.in/olivere/elastic.v5/client_test.go b/vendor/gopkg.in/olivere/elastic.v5/client_test.go
index 6caf7b797..4d0440ee0 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/client_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/client_test.go
@@ -279,6 +279,9 @@ func TestClientHealthcheckStartupTimeout(t *testing.T) {
if !IsConnErr(err) {
t.Fatal(err)
}
+ if !strings.Contains(err.Error(), "connection refused") {
+ t.Fatalf("expected error to contain %q, have %q", "connection refused", err.Error())
+ }
if duration < 5*time.Second {
t.Fatalf("expected a timeout in more than 5 seconds; got: %v", duration)
}
@@ -873,7 +876,10 @@ func TestPerformRequest(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- res, err := client.PerformRequest(context.TODO(), "GET", "/", nil, nil)
+ res, err := client.PerformRequest(context.TODO(), PerformRequestOptions{
+ Method: "GET",
+ Path: "/",
+ })
if err != nil {
t.Fatal(err)
}
@@ -895,7 +901,10 @@ func TestPerformRequestWithSimpleClient(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- res, err := client.PerformRequest(context.TODO(), "GET", "/", nil, nil)
+ res, err := client.PerformRequest(context.TODO(), PerformRequestOptions{
+ Method: "GET",
+ Path: "/",
+ })
if err != nil {
t.Fatal(err)
}
@@ -921,7 +930,10 @@ func TestPerformRequestWithLogger(t *testing.T) {
t.Fatal(err)
}
- res, err := client.PerformRequest(context.TODO(), "GET", "/", nil, nil)
+ res, err := client.PerformRequest(context.TODO(), PerformRequestOptions{
+ Method: "GET",
+ Path: "/",
+ })
if err != nil {
t.Fatal(err)
}
@@ -960,7 +972,10 @@ func TestPerformRequestWithLoggerAndTracer(t *testing.T) {
t.Fatal(err)
}
- res, err := client.PerformRequest(context.TODO(), "GET", "/", nil, nil)
+ res, err := client.PerformRequest(context.TODO(), PerformRequestOptions{
+ Method: "GET",
+ Path: "/",
+ })
if err != nil {
t.Fatal(err)
}
@@ -995,7 +1010,10 @@ func TestPerformRequestWithTracerOnError(t *testing.T) {
t.Fatal(err)
}
- client.PerformRequest(context.TODO(), "GET", "/no-such-index", nil, nil)
+ client.PerformRequest(context.TODO(), PerformRequestOptions{
+ Method: "GET",
+ Path: "/no-such-index",
+ })
tgot := tw.String()
if tgot == "" {
@@ -1019,7 +1037,10 @@ func TestPerformRequestWithCustomLogger(t *testing.T) {
t.Fatal(err)
}
- res, err := client.PerformRequest(context.TODO(), "GET", "/", nil, nil)
+ res, err := client.PerformRequest(context.TODO(), PerformRequestOptions{
+ Method: "GET",
+ Path: "/",
+ })
if err != nil {
t.Fatal(err)
}
@@ -1082,7 +1103,10 @@ func TestPerformRequestRetryOnHttpError(t *testing.T) {
t.Fatal(err)
}
- res, err := client.PerformRequest(context.TODO(), "GET", "/fail", nil, nil)
+ res, err := client.PerformRequest(context.TODO(), PerformRequestOptions{
+ Method: "GET",
+ Path: "/fail",
+ })
if err == nil {
t.Fatal("expected error")
}
@@ -1112,7 +1136,10 @@ func TestPerformRequestNoRetryOnValidButUnsuccessfulHttpStatus(t *testing.T) {
t.Fatal(err)
}
- res, err := client.PerformRequest(context.TODO(), "GET", "/fail", nil, nil)
+ res, err := client.PerformRequest(context.TODO(), PerformRequestOptions{
+ Method: "GET",
+ Path: "/fail",
+ })
if err == nil {
t.Fatal("expected error")
}
@@ -1141,7 +1168,11 @@ func TestPerformRequestWithSetBodyError(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- res, err := client.PerformRequest(context.TODO(), "GET", "/", nil, failingBody{})
+ res, err := client.PerformRequest(context.TODO(), PerformRequestOptions{
+ Method: "GET",
+ Path: "/",
+ Body: failingBody{},
+ })
if err == nil {
t.Fatal("expected error")
}
@@ -1178,7 +1209,10 @@ func TestPerformRequestWithCancel(t *testing.T) {
resc := make(chan result, 1)
go func() {
- res, err := client.PerformRequest(ctx, "GET", "/", nil, nil)
+ res, err := client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "GET",
+ Path: "/",
+ })
resc <- result{res: res, err: err}
}()
select {
@@ -1213,7 +1247,10 @@ func TestPerformRequestWithTimeout(t *testing.T) {
resc := make(chan result, 1)
go func() {
- res, err := client.PerformRequest(ctx, "GET", "/", nil, nil)
+ res, err := client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "GET",
+ Path: "/",
+ })
resc <- result{res: res, err: err}
}()
select {
@@ -1261,7 +1298,10 @@ func testPerformRequestWithCompression(t *testing.T, hc *http.Client) {
if err != nil {
t.Fatal(err)
}
- res, err := client.PerformRequest(context.TODO(), "GET", "/", nil, nil)
+ res, err := client.PerformRequest(context.TODO(), PerformRequestOptions{
+ Method: "GET",
+ Path: "/",
+ })
if err != nil {
t.Fatal(err)
}