forked from vitessio/vitess
-
Notifications
You must be signed in to change notification settings - Fork 1
/
testing.go
42 lines (36 loc) · 1.04 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
// Package test contains utilities to test topo.Impl
// 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"
"golang.org/x/net/context"
pb "github.com/youtube/vitess/go/vt/proto/topodata"
)
func newKeyRange(value string) key.KeyRange {
_, result, err := topo.ValidateShardName(value)
if err != nil {
panic(err)
}
return key.ProtoToKeyRange(result)
}
func newKeyRange3(value string) *pb.KeyRange {
_, result, err := topo.ValidateShardName(value)
if err != nil {
panic(err)
}
return result
}
func getLocalCell(ctx context.Context, t *testing.T, ts topo.Impl) string {
cells, err := ts.GetKnownCells(ctx)
if err != nil {
t.Fatalf("GetKnownCells: %v", err)
}
if len(cells) < 1 {
t.Fatalf("provided topo.Impl doesn't have enough cells (need at least 1): %v", cells)
}
return cells[0]
}