Debian Codegraph @

indices_forcemerge_test.go

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