use v5.30.0; use strict; use warnings; use Test::Most tests => 5; use Test::MockModule; use Peace::Model::Application; use Peace::Model::Developer; use DBI; BEGIN { use_ok 'Peace::Model::Release'; } { ## 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_flatpak_repo = 'https://nightly.gnome.org/gnome-nightly.flatpakrepo'; 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, flatpak_repo => $app_flatpak_repo, verified => $app_verified, git_repo => $app_git_repo, ); my $release_name = '0.0.1'; my $release_tag = 'v0.0.1'; ## WHEN my $release = Peace::Model::Release->new( name => $release_name, application => $release_application, tag => $release_tag ); ## THEN ok $release->isa('Peace::Model::Release'), 'Instanced release is made of Peace::Model::Release.'; 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_flatpak_repo = 'https://nightly.gnome.org/gnome-nightly.flatpakrepo'; 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, flatpak_repo => $app_flatpak_repo, 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.'; }