Skip to content

Commit a0c9b89

Browse files
committed
add a test
Signed-off-by: Nick Van Wiggeren <[email protected]>
1 parent fd858d7 commit a0c9b89

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

go/vt/vtgate/executor_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3355,6 +3355,47 @@ func TestExecutorShowShards(t *testing.T) {
33553355
destTabletType: topodatapb.TabletType_PRIMARY,
33563356
wantErr: "testing error getting keyspace ks1",
33573357
},
3358+
{
3359+
// Test that deleted keyspaces (returning NoNode error) are skipped
3360+
// rather than causing the entire query to fail.
3361+
name: "Deleted keyspace (NoNode) should be skipped",
3362+
srvTopoServer: &fakesrvtopo.FakeSrvTopo{
3363+
SrvKeyspaceNamesOutput: map[string][]string{
3364+
localCell: {"ks1", "ks2"},
3365+
},
3366+
SrvKeyspaceError: map[string]map[string]error{
3367+
localCell: {
3368+
"ks1": topo.NewError(topo.NoNode, "ks1"),
3369+
},
3370+
},
3371+
SrvKeyspaceOutput: map[string]map[string]*topodatapb.SrvKeyspace{
3372+
localCell: {
3373+
"ks2": {
3374+
Partitions: []*topodatapb.SrvKeyspace_KeyspacePartition{
3375+
{
3376+
ServedType: topodatapb.TabletType_PRIMARY,
3377+
ShardReferences: []*topodatapb.ShardReference{
3378+
{Name: "-40"},
3379+
{Name: "40-80"},
3380+
{Name: "80-"},
3381+
},
3382+
},
3383+
},
3384+
},
3385+
},
3386+
},
3387+
},
3388+
filter: nil,
3389+
destTabletType: topodatapb.TabletType_PRIMARY,
3390+
want: &sqltypes.Result{
3391+
Fields: buildVarCharFields("Shards"),
3392+
Rows: []sqltypes.Row{
3393+
buildVarCharRow("ks2/-40"),
3394+
buildVarCharRow("ks2/40-80"),
3395+
buildVarCharRow("ks2/80-"),
3396+
},
3397+
},
3398+
},
33583399
}
33593400
for _, tt := range tests {
33603401
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)