Peace/db_tests/00002-developer-dao.t

44 lines
1.0 KiB
Perl
Raw Normal View History

#!/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.';
}