Peace/db_tests/00004-release-dao.t

59 lines
1.5 KiB
Perl
Raw Normal View History

#!/usr/bin/env perl
use v5.30.0;
use strict;
use warnings;
use Data::Dumper;
use Test::Most tests => 2;
use DateTime;
use Peace;
use Peace::DB;
use Peace::DAO::Developer;
use Peace::DAO::Application;
use Peace::DAO::Release;
use Peace::Test::Mock::Model::Developer;
use Peace::Test::Mock::Model::Application;
use Peace::Test::Mock::Model::Release;
{
## 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 $developer = Peace::Test::Mock::Model::Developer->new;
my $developer_dao = Peace::DAO::Developer->new( dbh => $dbh );
$developer_dao->create( developer => $developer );
my $application = Peace::Test::Mock::Model::Application->new;
$application->developer($developer);
my $application_dao = Peace::DAO::Application->new( dbh => $dbh );
$application->app_id("com.example.desfronificator@{[int(rand(10000000))]}");
$application_dao->create( application => $application );
my $release = Peace::Test::Mock::Model::Release->new;
$release->application($application);
my $release_dao = Peace::DAO::Release->new( dbh => $dbh );
## WHEN
$release_dao->create( release => $release );
## THEN
ok $release->uuid, 'Generated uuid.';
ok $release->date_creation > $current_date, 'The date is recent.';
}