Adding test for the recovery from uuid of application.
This commit is contained in:
parent
436edcef00
commit
ea7c5b7471
@ -36,6 +36,11 @@ use Types::Standard qw/InstanceOf Str HasMethods/;
|
||||
}
|
||||
}
|
||||
|
||||
sub _dbh {
|
||||
my $self = shift;
|
||||
return $self->{dbh};
|
||||
}
|
||||
|
||||
{
|
||||
my $validator =
|
||||
validation_for( params => [ { type => Str, optional => 1 } ] );
|
||||
|
@ -3,11 +3,14 @@ use v5.30.0;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Test::Most tests => 4;
|
||||
use Test::Most tests => 5;
|
||||
use Test::MockModule;
|
||||
|
||||
use Peace::Model::Application;
|
||||
use Peace::Model::Developer;
|
||||
|
||||
use DBI;
|
||||
|
||||
BEGIN {
|
||||
use_ok 'Peace::Model::Release';
|
||||
}
|
||||
@ -66,3 +69,65 @@ BEGIN {
|
||||
is $release->name, $release_name, 'Name is correctly setup';
|
||||
is $release->uuid, undef, 'Uuid is undef.';
|
||||
}
|
||||
|
||||
{
|
||||
## GIVEN
|
||||
### Developer data.
|
||||
my $developer_secret_bcrypt = 'hola';
|
||||
my $developer_name = 'Larry';
|
||||
my $developer_surname = 'Wall';
|
||||
my $developer_email = 'larry@perl.org';
|
||||
my $developer_country = 'US';
|
||||
my $developer_verified = 0;
|
||||
|
||||
### Application data.
|
||||
my $app_name = 'Desfronificator';
|
||||
my $app_description = 'Desfronifies the files.';
|
||||
my $app_url = 'https://desfronificator.example.com';
|
||||
my $app_price = '4.20';
|
||||
my $app_git_repo =
|
||||
'https://git.desfronificator.example.com/larry/desfronificator.git';
|
||||
my $app_flatpak_builder_file =
|
||||
'./resources/com.example.desfronificator.yml';
|
||||
my $app_verified = 0;
|
||||
my $app_developer = Peace::Model::Developer->new(
|
||||
secret_bcrypt => $developer_secret_bcrypt,
|
||||
name => $developer_name,
|
||||
surname => $developer_surname,
|
||||
email => $developer_email,
|
||||
country => $developer_country,
|
||||
verified => $developer_verified,
|
||||
);
|
||||
### Release data.
|
||||
my $release_application = Peace::Model::Application->new(
|
||||
developer => $app_developer,
|
||||
name => $app_name,
|
||||
description => $app_description,
|
||||
url => $app_url,
|
||||
price => $app_price,
|
||||
flatpak_builder_file => $app_flatpak_builder_file,
|
||||
verified => $app_verified,
|
||||
git_repo => $app_git_repo,
|
||||
);
|
||||
my $release_application_uuid = 'exampleuuid';
|
||||
my $release_name = '0.0.1';
|
||||
my $release_tag = 'v0.0.1';
|
||||
my $release_dbh = DBI->connect('dbi:Mock:');
|
||||
my $application_dao_mock_module =
|
||||
Test::MockModule->new('Peace::DAO::Application');
|
||||
$application_dao_mock_module->mock(
|
||||
recover_by_uuid => sub {
|
||||
return $release_application;
|
||||
}
|
||||
);
|
||||
|
||||
## WHEN
|
||||
my $release = Peace::Model::Release->new(
|
||||
name => $release_name,
|
||||
application_uuid => $release_application_uuid,
|
||||
tag => $release_tag,
|
||||
dbh => $release_dbh,
|
||||
);
|
||||
## THEN
|
||||
is $release->application, $release_application, 'Uuid is undef.';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user