snapshot_get_repository_test.go 778 B

123456789101112131415161718192021222324252627282930313233343536373839
  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 "testing"
  6. func TestSnapshotGetRepositoryURL(t *testing.T) {
  7. client := setupTestClient(t)
  8. tests := []struct {
  9. Repository []string
  10. Expected string
  11. }{
  12. {
  13. []string{},
  14. "/_snapshot",
  15. },
  16. {
  17. []string{"repo1"},
  18. "/_snapshot/repo1",
  19. },
  20. {
  21. []string{"repo1", "repo2"},
  22. "/_snapshot/repo1%2Crepo2",
  23. },
  24. }
  25. for _, test := range tests {
  26. path, _, err := client.SnapshotGetRepository(test.Repository...).buildURL()
  27. if err != nil {
  28. t.Fatal(err)
  29. }
  30. if path != test.Expected {
  31. t.Errorf("expected %q; got: %q", test.Expected, path)
  32. }
  33. }
  34. }