Debian Codegraph @

indices_get_mapping_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 "testing"
9 )
10
11 func TestIndicesGetMappingURL(t *testing.T) {
12 client := setupTestClientAndCreateIndex(t)
13
14 tests := []struct {
15 Indices []string
16 Types []string
17 Expected string
18 }{
19 {
20 []string{},
21 []string{},
22 "/_all/_mapping/_all",
23 },
24 {
25 []string{},
26 []string{"tweet"},
27 "/_all/_mapping/tweet",
28 },
29 {
30 []string{"twitter"},
31 []string{"tweet"},
32 "/twitter/_mapping/tweet",
33 },
34 {
35 []string{"store-1", "store-2"},
36 []string{"tweet", "user"},
37 "/store-1%2Cstore-2/_mapping/tweet%2Cuser",
38 },
39 }
40
41 for _, test := range tests {
42 path, _, err := client.GetMapping().Index(test.Indices...).Type(test.Types...).buildURL()
43 if err != nil {
44 t.Fatal(err)
45 }
46 if path != test.Expected {
47 t.Errorf("expected %q; got: %q", test.Expected, path)
48 }
49 }
50 }