File: 01-connect.t

package info (click to toggle)
libcassandra-client-perl 0.21-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 716 kB
  • sloc: perl: 3,898; ansic: 1,767; makefile: 3
file content (70 lines) | stat: -rw-r--r-- 1,218 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!perl
use 5.010;
use strict;
use warnings;
use File::Basename qw//; use lib File::Basename::dirname(__FILE__).'/lib';
use Test::More;
use TestCassandra;
use AnyEvent;

# Add some junk into our Perl magic variables
local $"= "junk join string ,";
local $/= "junk slurp";
local $\= "abcdef";

plan skip_all => "Missing Cassandra test environment" unless TestCassandra->is_ok;
plan tests => 4;

{
    my $cv= AnyEvent->condvar;

    my $client= TestCassandra->new( anyevent => 1 );
    $client->async_connect->then(sub {
        $client->shutdown

    })->then(sub {
        $cv->send;
        ok(1);
    }, sub {
        $cv->send;
        ok(0) or diag($_[0]);
    });

    $cv->recv;
}



{
    my $client= TestCassandra->new;
    eval {
        $client->connect;
        $client->shutdown;
        ok(1);
        1;
    } or do {
        ok(0) or diag($@);
    };
}

{
    my $client= TestCassandra->new;
    my ($error)= $client->call_connect;
    ok(!$error) or diag($error);

    $client->shutdown;
}

{
    my $client= TestCassandra->new;
    eval {
        my $cfuture= $client->future_connect;
        $cfuture->();

        $client->shutdown;

        ok(1);
    } or do {
        ok(0) or diag($@);
    };
}