DBIO-PostgreSQL-Age
view release on metacpan or search on metacpan
t/11-age-deploy.t view on Meta::CPAN
my $persons = $schema->storage->cypher(
'deploy_test',
q[ MATCH (p:Person) RETURN p.name ORDER BY p.name ],
['name'],
);
is(scalar @$persons, 3, 'three persons after first deploy');
my $edges = $schema->storage->cypher(
'deploy_test',
q[ MATCH ()-[r:KNOWS]->() RETURN count(r) AS n ],
['n'],
);
like($edges->[0]{n}, qr/3/, 'three KNOWS edges after first deploy');
};
# --- Deploy again: must be idempotent ---------------------------------------
subtest 'second deploy is idempotent' => sub {
$deploy_fixtures->();
my $persons = $schema->storage->cypher(
'deploy_test',
q[ MATCH (p:Person) RETURN p.name ORDER BY p.name ],
['name'],
);
is(scalar @$persons, 3,
'still three persons after second deploy (no duplicates)');
my $edges = $schema->storage->cypher(
'deploy_test',
q[ MATCH ()-[r:KNOWS]->() RETURN count(r) AS n ],
['n'],
);
like($edges->[0]{n}, qr/3/,
'still three KNOWS edges after second deploy (no duplicates)');
# Properties updated by SET during deploy survive.
my $alice = $schema->storage->cypher(
'deploy_test',
q[ MATCH (p:Person {name: 'Alice'}) RETURN p.age, p.role ],
[qw(age role)],
undef,
{ auto_decode => 1 },
);
is($alice->[0]{age}, 30, 'Alice age unchanged after second deploy');
is($alice->[0]{role}, 'admin', 'Alice role unchanged after second deploy');
};
# --- auto_decode round-trip in deploy context -------------------------------
subtest 'auto_decode works on a deployed graph' => sub {
my $rows = $schema->storage->cypher(
'deploy_test',
q[ MATCH (p:Person {name: $name})-[:KNOWS]->(friend) RETURN friend.name, friend.age ],
[qw(name age)],
{ name => 'Alice' },
{ auto_decode => 1 },
);
is(scalar @$rows, 2, 'Alice has two outgoing KNOWS edges');
my @friends = sort map { $_->{name} } @$rows;
is_deeply(\@friends, [qw(Bob Carol)],
'auto_decode returns friend names as decoded strings');
};
done_testing;
( run in 0.934 second using v1.01-cache-2.11-cpan-600a1bdf6e4 )