Adding functional test of database integration.
Since the project is not functional still I made the changes needed in database in order of it to work directly over the creation migration.
This commit is contained in:
parent
94eafe55a2
commit
156e69c825
43
db_tests/00002-developer-dao.t
Normal file
43
db_tests/00002-developer-dao.t
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
|
use v5.30.0;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
use Test::Most tests => 2;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
|
|
||||||
|
use Peace;
|
||||||
|
use Peace::DB;
|
||||||
|
use Peace::Model::Developer;
|
||||||
|
use Peace::DAO::Developer;
|
||||||
|
|
||||||
|
{
|
||||||
|
## GIVEN
|
||||||
|
my $current_date = DateTime->now;
|
||||||
|
my $peace = Peace->new;
|
||||||
|
my $home = $ENV{HOME};
|
||||||
|
my $config =
|
||||||
|
$peace->plugin(
|
||||||
|
JSONConfig => { file => "$home/.config/peace/peace.conf" } );
|
||||||
|
my $dbh = Peace::DB->dbh( config => $config );
|
||||||
|
my $secret_bcrypt = 'hola';
|
||||||
|
my $developer = Peace::Model::Developer->new(
|
||||||
|
name => 'Larry',
|
||||||
|
surname => 'Wall',
|
||||||
|
email => 'larry@perl.org',
|
||||||
|
country => 'US',
|
||||||
|
verified => 0,
|
||||||
|
secret_bcrypt => $secret_bcrypt
|
||||||
|
);
|
||||||
|
my $developer_dao = Peace::DAO::Developer->new( dbh => $dbh );
|
||||||
|
|
||||||
|
## WHEN
|
||||||
|
$developer_dao->create( developer => $developer );
|
||||||
|
|
||||||
|
## THEN
|
||||||
|
ok $developer->uuid, 'Generated uuid.';
|
||||||
|
ok $developer->date_creation > $current_date, 'The date is recent.';
|
||||||
|
}
|
@ -31,7 +31,7 @@ my @migrations = (
|
|||||||
name TEXT NOT NULL,
|
name TEXT NOT NULL,
|
||||||
surname TEXT NOT NULL,
|
surname TEXT NOT NULL,
|
||||||
email TEXT NOT NULL,
|
email TEXT NOT NULL,
|
||||||
stripe_id TEXT NOT NULL,
|
stripe_id TEXT,
|
||||||
country TEXT NOT NULL,
|
country TEXT NOT NULL,
|
||||||
verified BOOL DEFAULT false,
|
verified BOOL DEFAULT false,
|
||||||
PRIMARY KEY (uuid)
|
PRIMARY KEY (uuid)
|
||||||
|
Loading…
Reference in New Issue
Block a user