| 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 ( |
| 8 |
"context" |
| 9 |
"testing" |
| 10 |
) |
| 11 |
|
| 12 |
func TestSearchShards(t *testing.T) { |
| 13 |
client := setupTestClientAndCreateIndex(t) |
| 14 |
|
| 15 |
indexes := []string{testIndexName} |
| 16 |
|
| 17 |
shardsInfo, err := client.SearchShards(indexes...).Do(context.TODO()) |
| 18 |
if err != nil { |
| 19 |
t.Fatal(err) |
| 20 |
} |
| 21 |
if shardsInfo == nil { |
| 22 |
t.Fatal("expected to return an shards information") |
| 23 |
} |
| 24 |
if len(shardsInfo.Shards) < 1 { |
| 25 |
t.Fatal("expected to return minimun one shard information") |
| 26 |
} |
| 27 |
|
| 28 |
if shardsInfo.Shards[0][0].Index != testIndexName { |
| 29 |
t.Fatal("expected to return shard info concerning requested index") |
| 30 |
} |
| 31 |
|
| 32 |
if shardsInfo.Shards[0][0].State != "STARTED" { |
| 33 |
t.Fatal("expected to return STARTED status for running shards") |
| 34 |
} |
| 35 |
} |