indices_get_mapping_test.go 1001 B

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