Peace/db_tests/00001-customer-dao.t

37 lines
843 B
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::Customer;
use Peace::DAO::Customer;
{
## 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 $customer = Peace::Model::Customer->new( secret_bcrypt => $secret_bcrypt );
my $customer_dao = Peace::DAO::Customer->new( dbh => $dbh );
## WHEN
$customer_dao->create( customer => $customer );
## THEN
ok $customer->uuid, 'Generated uuid.';
ok $customer->date_creation > $current_date, 'The date is recent.';
}