本文整理汇总了Golang中github.com/youtube/vitess/go/vt/vtgate/vtgateconn.VTGateConn.ExecuteShard方法的典型用法代码示例。如果您正苦于以下问题:Golang VTGateConn.ExecuteShard方法的具体用法?Golang VTGateConn.ExecuteShard怎么用?Golang VTGateConn.ExecuteShard使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/youtube/vitess/go/vt/vtgate/vtgateconn.VTGateConn
的用法示例。
在下文中一共展示了VTGateConn.ExecuteShard方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: testExecuteShard
func testExecuteShard(t *testing.T, conn *vtgateconn.VTGateConn) {
ctx := context.Background()
execCase := execMap["request1"]
qr, err := conn.ExecuteShard(ctx, execCase.shardQuery.Sql, execCase.shardQuery.Keyspace, execCase.shardQuery.Shards, execCase.shardQuery.BindVariables, execCase.shardQuery.TabletType)
if err != nil {
t.Error(err)
}
if !reflect.DeepEqual(qr, execCase.reply.Result) {
t.Errorf("Unexpected result from Execute: got %+v want %+v", qr, execCase.reply.Result)
}
_, err = conn.ExecuteShard(ctx, "none", "", []string{}, nil, "")
want := "no match for: none"
if err == nil || !strings.Contains(err.Error(), want) {
t.Errorf("none request: %v, want %v", err, want)
}
_, err = conn.ExecuteShard(ctx, "errorRequst", "", []string{}, nil, "")
want = "app error"
if err == nil || err.Error() != want {
t.Errorf("errorRequst: %v, want %v", err, want)
}
}
示例2: testExecuteShardPanic
func testExecuteShardPanic(t *testing.T, conn *vtgateconn.VTGateConn) {
ctx := context.Background()
execCase := execMap["request1"]
_, err := conn.ExecuteShard(ctx, execCase.execQuery.Sql, "ks", []string{"1", "2"}, execCase.execQuery.BindVariables, execCase.execQuery.TabletType)
expectPanic(t, err)
}