forked from vitessio/vitess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testing.go
31 lines (27 loc) · 794 Bytes
/
testing.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// package test contains utilities to test topo.Server
// implementations. If you are testing your implementation, you will
// want to call CheckAll in your test method. For an example, look at
// the tests in github.com/youtube/vitess/go/vt/zktopo.
package test
import (
"testing"
"github.com/youtube/vitess/go/vt/key"
"github.com/youtube/vitess/go/vt/topo"
)
func newKeyRange(value string) key.KeyRange {
_, result, err := topo.ValidateShardName(value)
if err != nil {
panic(err)
}
return result
}
func getLocalCell(t *testing.T, ts topo.Server) string {
cells, err := ts.GetKnownCells()
if err != nil {
t.Fatalf("GetKnownCells: %v", err)
}
if len(cells) < 1 {
t.Fatalf("provided topo.Server doesn't have enough cells (need at least 1): %v", cells)
}
return cells[0]
}