File: Apache-Session-Browseable-Patroni.t

package info (click to toggle)
libapache-session-browseable-perl 1.3.18-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 372 kB
  • sloc: perl: 2,058; makefile: 2
file content (53 lines) | stat: -rw-r--r-- 1,189 bytes parent folder | download
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
use Test::More;

plan skip_all => "Optional modules (DBD::Pg, DBI) not installed"
  unless eval {
    require DBI;
    require DBD::Pg;
  };

$package = 'Apache::Session::Browseable::Store::Patroni';

use_ok($package);

my $foo = $package->new;

isa_ok $foo, $package;

$package = 'Apache::Session::Browseable::Patroni';
use_ok($package);

SKIP: {
    skip 'No patroniUrl, skipping', 1 unless $ENV{PATRONI_URL};
    my $args = {
        DataSource => 'dbi:Pg:dbname=sessions;host='
          . ( $ENV{PG_HOST} || '127.25.76.98:port=300' ),
        UserName   => 'postgres',
        Password   => 'postgres',
        PatroniUrl => $ENV{PATRONI_URL},
    };

    my %h;
    tie %h, $package, undef, $args;
    ok( %h && $h{_session_id}, 'Hash populated' );
    my $id = $h{_session_id};
    $h{a} = 'aa';
    untie %h;
    %h = ();
    tie %h, $package, $id, $args;
    is( $h{a}, 'aa', 'data stored' );
    untie %h;
    if ($ENV{PATRONI_NEXT}) {
        diag `$ENV{PATRONI_NEXT}`;
        sleep 1;
    }
    tie %h, $package, $id, $args;
    $h{a} = 'bb';
    untie %h;
    %h = ();
    tie %h, $package, $id, $args;
    is( $h{a}, 'bb', 'data changed' );
    untie %h;
}

done_testing();