indices_get_template_test.go 791 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 TestIndexGetTemplateURL(t *testing.T) {
  9. client := setupTestClientAndCreateIndex(t)
  10. tests := []struct {
  11. Names []string
  12. Expected string
  13. }{
  14. {
  15. []string{},
  16. "/_template",
  17. },
  18. {
  19. []string{"index1"},
  20. "/_template/index1",
  21. },
  22. {
  23. []string{"index1", "index2"},
  24. "/_template/index1%2Cindex2",
  25. },
  26. }
  27. for _, test := range tests {
  28. path, _, err := client.IndexGetTemplate().Name(test.Names...).buildURL()
  29. if err != nil {
  30. t.Fatal(err)
  31. }
  32. if path != test.Expected {
  33. t.Errorf("expected %q; got: %q", test.Expected, path)
  34. }
  35. }
  36. }