// RegisterFakeVTGateConnDialer registers the proper dialer for this fake, // and returns the underlying instance that will be returned by the dialer, // and the protocol to use to get this fake. func RegisterFakeVTGateConnDialer() (*FakeVTGateConn, string) { protocol := "fake" impl := &FakeVTGateConn{ execMap: make(map[string]*queryResponse), splitQueryMap: make(map[string]*splitQueryResponse), } vtgateconn.RegisterDialer(protocol, func(ctx context.Context, address string, timeout time.Duration) (vtgateconn.Impl, error) { return impl, nil }) return impl, protocol }
// TestSuite runs all the tests func TestSuite(t *testing.T, impl vtgateconn.Impl, fakeServer vtgateservice.VTGateService) { vtgateconn.RegisterDialer("test", func(ctx context.Context, address string, timeout time.Duration) (vtgateconn.Impl, error) { return impl, nil }) conn, _ := vtgateconn.DialProtocol(context.Background(), "test", "", 0) testExecute(t, conn) testExecuteShard(t, conn) testExecuteKeyspaceIds(t, conn) testExecuteKeyRanges(t, conn) testExecuteEntityIds(t, conn) testExecuteBatchShard(t, conn) testExecuteBatchKeyspaceIds(t, conn) testStreamExecute(t, conn) testStreamExecuteShard(t, conn) testStreamExecuteKeyRanges(t, conn) testStreamExecuteKeyspaceIds(t, conn) testTxPass(t, conn) testTxPassNotInTransaction(t, conn) testTxFail(t, conn) testSplitQuery(t, conn) // force a panic at every call, then test that works fakeServer.(*fakeVTGateService).panics = true testExecutePanic(t, conn) testExecuteShardPanic(t, conn) testExecuteKeyspaceIdsPanic(t, conn) testExecuteKeyRangesPanic(t, conn) testExecuteEntityIdsPanic(t, conn) testExecuteBatchShardPanic(t, conn) testExecuteBatchKeyspaceIdsPanic(t, conn) testStreamExecutePanic(t, conn) testStreamExecuteShardPanic(t, conn) testStreamExecuteKeyRangesPanic(t, conn) testStreamExecuteKeyspaceIdsPanic(t, conn) testBeginPanic(t, conn) testSplitQueryPanic(t, conn) }
func init() { vtgateconn.RegisterDialer("grpc", dial) }
func init() { vtgateconn.RegisterDialer("bsonp3", dial) }