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