File: timestamp_order.t

package info (click to toggle)
libdbix-class-encodedcolumn-perl 0.00020-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 236 kB
  • sloc: perl: 616; sql: 48; makefile: 2
file content (40 lines) | stat: -rw-r--r-- 1,393 bytes parent folder | download | duplicates (3)
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
use strict;
use warnings;
use Test::More;
use utf8;
use Dir::Self;
use File::Spec;
use File::Temp 'tempdir';
use lib File::Spec->catdir(__DIR__, '..', 'lib');
use DigestTest::Schema;

BEGIN {
  unless ($ENV{AUTHOR_TESTING}) {
    plan skip_all => 'These are for testing by the author';
    exit;
  }
  unless( eval 'require DBIx::Class::TimeStamp' ) {
    plan skip_all => 'DBIx::Class::TimeStamp not available';
    exit;
  }
}

DigestTest::Schema->load_classes(qw/WithTimeStampChild WithTimeStampChildWrongOrder/);

my $tmp = tempdir( CLEANUP => 1 );
my $db_file = File::Spec->catfile($tmp, 'testdb.sqlite');
my $schema = DigestTest::Schema->connect("dbi:SQLite:dbname=${db_file}");
$schema->deploy({}, File::Spec->catdir(__DIR__, '..', 'var'));

my %create_values = (username => 'testuser', password => 'password1');
my $row = $schema->resultset('WithTimeStampChild')->create( \%create_values );
ok($row->password ne 'password1','password has been encrypted');
ok($row->created,'... and created has been set');
ok(!$row->updated,'... and updated has not been set');
$row->update({username => 'testuser2'});
ok($row->updated,'when updated, updated has now been set');

my $row_wrong = $schema->resultset('WithTimeStampChildWrongOrder')->create( \%create_values );
ok($row_wrong->password eq 'password1','with the wrong order of components password has not been encrypted');

done_testing();