コード例 #1
0
ファイル: client.go プロジェクト: pranjal5215/vitess
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
0
ファイル: client.go プロジェクト: pranjal5215/vitess
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)
}