delete_mapping_test.go 859 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright 2012-2015 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 TestDeleteMappingURL(t *testing.T) {
  9. client := setupTestClientAndCreateIndex(t)
  10. tests := []struct {
  11. Indices []string
  12. Types []string
  13. Expected string
  14. }{
  15. {
  16. []string{"twitter"},
  17. []string{"tweet"},
  18. "/twitter/_mapping/tweet",
  19. },
  20. {
  21. []string{"store-1", "store-2"},
  22. []string{"tweet", "user"},
  23. "/store-1%2Cstore-2/_mapping/tweet%2Cuser",
  24. },
  25. }
  26. for _, test := range tests {
  27. path, _, err := client.DeleteMapping().Index(test.Indices...).Type(test.Types...).buildURL()
  28. if err != nil {
  29. t.Fatal(err)
  30. }
  31. if path != test.Expected {
  32. t.Errorf("expected %q; got: %q", test.Expected, path)
  33. }
  34. }
  35. }