indices_forcemerge_test.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 (
  6. "context"
  7. "testing"
  8. )
  9. func TestIndicesForcemergeBuildURL(t *testing.T) {
  10. client := setupTestClient(t)
  11. tests := []struct {
  12. Indices []string
  13. Expected string
  14. }{
  15. {
  16. []string{},
  17. "/_forcemerge",
  18. },
  19. {
  20. []string{"index1"},
  21. "/index1/_forcemerge",
  22. },
  23. {
  24. []string{"index1", "index2"},
  25. "/index1%2Cindex2/_forcemerge",
  26. },
  27. }
  28. for i, test := range tests {
  29. path, _, err := client.Forcemerge().Index(test.Indices...).buildURL()
  30. if err != nil {
  31. t.Errorf("case #%d: %v", i+1, err)
  32. continue
  33. }
  34. if path != test.Expected {
  35. t.Errorf("case #%d: expected %q; got: %q", i+1, test.Expected, path)
  36. }
  37. }
  38. }
  39. func TestIndicesForcemerge(t *testing.T) {
  40. client := setupTestClientAndCreateIndexAndAddDocs(t)
  41. _, err := client.Forcemerge(testIndexName).MaxNumSegments(1).Do(context.TODO())
  42. if err != nil {
  43. t.Fatal(err)
  44. }
  45. /*
  46. if !ok {
  47. t.Fatalf("expected forcemerge to succeed; got: %v", ok)
  48. }
  49. */
  50. }