DR-Tarantool

 view release on metacpan or  search on metacpan

t/080-tarantool.t  view on Meta::CPAN

    isa_ok $t => 'DR::Tarantool::Tuple';
    is $t->key, '-121', 'key(-121)';
    is $t->balance, '-2.34', 'money(-2.34)';
    $t = $client->update(first_space => 2 =>
        [
            [ balance => add => '-1.12' ],
            [ key     => add => -101 ],
        ],
        TNT_FLAG_RETURN
    );
    isa_ok $t => 'DR::Tarantool::Tuple';
    is $t->key, '-222', 'key(-222)';
    is $t->balance, '-3.46', 'money(-3.46)';
    $t = $client->update(first_space => 2 =>
        [
            [ balance => add => '5.17' ],
            [ key     => add => 777 ],
        ],
        TNT_FLAG_RETURN
    );
    isa_ok $t => 'DR::Tarantool::Tuple';
    is $t->key, '555', 'key(555)';
    is $t->balance, '1.71', 'money(1.71)';



    # connect
    for my $cv (condvar AnyEvent) {
        DR::Tarantool::AsyncClient->connect(
            port                    => $tnt->primary_port,
            reconnect_period        => 0.1,
            spaces                  => $spaces,
            cb      => sub {
                $client = shift;
                $cv->send;
            }
        );

        $cv->recv;
    }
    unless ( isa_ok $client => 'DR::Tarantool::AsyncClient' ) {
        diag eval { decode utf8 => $client } || $client;
        last;
    }


    # ping
    for my $cv (condvar AnyEvent) {
        $client->ping(
            sub {
                my ($status) = @_;
                is $status, 'ok', '* async_tarantool ping';
                $cv->send;
            }
        );
        $cv->recv;
    }

    eval "require Coro";
    skip "Coro isn't installed", 2 if $@;
    $client = coro_tarantool
        port    => $tnt->primary_port,
        spaces  => $spaces
    ;
    isa_ok $client => 'DR::Tarantool::CoroClient';
    ok $client->ping, '* coro_tarantool ping';
}



( run in 1.235 second using v1.01-cache-2.11-cpan-39bf76dae61 )