| 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 |
|
| 5 |
package elastic |
| 6 |
|
| 7 |
import "testing" |
| 8 |
|
| 9 |
func TestTasksCancelBuildURL(t *testing.T) { |
| 10 |
client := setupTestClient(t) |
| 11 |
|
| 12 |
// Cancel all |
| 13 |
got, _, err := client.TasksCancel().buildURL() |
| 14 |
if err != nil { |
| 15 |
t.Fatal(err) |
| 16 |
} |
| 17 |
want := "/_tasks/_cancel" |
| 18 |
if got != want { |
| 19 |
t.Errorf("want %q; got %q", want, got) |
| 20 |
} |
| 21 |
|
| 22 |
// Cancel specific task |
| 23 |
got, _, err = client.TasksCancel().TaskId(42).buildURL() |
| 24 |
if err != nil { |
| 25 |
t.Fatal(err) |
| 26 |
} |
| 27 |
want = "/_tasks/42/_cancel" |
| 28 |
if got != want { |
| 29 |
t.Errorf("want %q; got %q", want, got) |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
/* |
| 34 |
func TestTasksCancel(t *testing.T) { |
| 35 |
client := setupTestClientAndCreateIndexAndAddDocs(t) |
| 36 |
esversion, err := client.ElasticsearchVersion(DefaultURL) |
| 37 |
if err != nil { |
| 38 |
t.Fatal(err) |
| 39 |
} |
| 40 |
if esversion < "2.3.0" { |
| 41 |
t.Skipf("Elasticsearch %v does not support Tasks Management API yet", esversion) |
| 42 |
} |
| 43 |
res, err := client.TasksCancel("1").Do(context.TODO()) |
| 44 |
if err != nil { |
| 45 |
t.Fatal(err) |
| 46 |
} |
| 47 |
if res == nil { |
| 48 |
t.Fatal("response is nil") |
| 49 |
} |
| 50 |
} |
| 51 |
*/ |