tasks_cancel_test.go 1.1 KB

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