@@ -18,27 +18,37 @@ func TestParseTablets(t *testing.T) {
1818 case "/api/keyspace/test/tablets/00" :
1919 data , _ := json .Marshal ([]Tablet {
2020 {
21+ Alias : & topodata.TabletAlias {Cell : "ash1" },
2122 MysqlHostname : "master" ,
2223 Type : topodata .TabletType_MASTER ,
2324 },
2425 {
26+ Alias : & topodata.TabletAlias {Cell : "ac4" },
2527 MysqlHostname : "replica" ,
2628 Type : topodata .TabletType_REPLICA ,
2729 },
2830 {
31+ Alias : & topodata.TabletAlias {Cell : "va3" },
32+ MysqlHostname : "replica" ,
33+ Type : topodata .TabletType_REPLICA ,
34+ },
35+ {
36+ Alias : & topodata.TabletAlias {Cell : "ac4" },
2937 MysqlHostname : "spare" ,
3038 Type : topodata .TabletType_SPARE ,
3139 },
3240 {
41+ Alias : & topodata.TabletAlias {Cell : "va3" },
3342 MysqlHostname : "batch" ,
3443 Type : topodata .TabletType_BATCH ,
3544 },
3645 {
46+ Alias : & topodata.TabletAlias {Cell : "ac4" },
3747 MysqlHostname : "backup" ,
3848 Type : topodata .TabletType_BACKUP ,
3949 },
4050 {
41-
51+ Alias : & topodata. TabletAlias { Cell : "ash1" },
4252 MysqlHostname : "restore" ,
4353 Type : topodata .TabletType_RESTORE ,
4454 },
@@ -62,8 +72,8 @@ func TestParseTablets(t *testing.T) {
6272 t .Fatalf ("Expected no error, got %q" , err )
6373 }
6474
65- if len (tablets ) != 1 {
66- t .Fatalf ("Expected 1 tablet , got %d" , len (tablets ))
75+ if len (tablets ) != 2 {
76+ t .Fatalf ("Expected 2 tablets , got %d" , len (tablets ))
6777 }
6878
6979 if tablets [0 ].MysqlHostname != "replica" {
@@ -75,6 +85,26 @@ func TestParseTablets(t *testing.T) {
7585 }
7686 })
7787
88+ t .Run ("with-cell" , func (t * testing.T ) {
89+ tablets , err := ParseTablets (config.VitessConfigurationSettings {
90+ API : vitessApi .URL ,
91+ Cell : "ac4" ,
92+ Keyspace : "test" ,
93+ Shard : "00" ,
94+ })
95+ if err != nil {
96+ t .Fatalf ("Expected no error, got %q" , err )
97+ }
98+
99+ if len (tablets ) > 1 {
100+ t .Fatalf ("Expected 1 tablet, got %d" , len (tablets ))
101+ }
102+
103+ if tablets [0 ].Alias .Cell != "ac4" {
104+ t .Fatalf ("Expected vitess cell %s, got %s" , "ac4" , tablets [0 ].Alias .Cell )
105+ }
106+ })
107+
78108 t .Run ("not-found" , func (t * testing.T ) {
79109 tablets , err := ParseTablets (config.VitessConfigurationSettings {
80110 API : vitessApi .URL ,
0 commit comments