2022-03-16 16:11:27 +01:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
|
|
|
use v5.30.0;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
use Test::Most tests => 4;
|
|
|
|
use Test::MockModule;
|
|
|
|
|
|
|
|
use DBI;
|
|
|
|
|
|
|
|
use Peace::Model::Developer;
|
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
use_ok 'Peace::Model::Application';
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
## GIVEN
|
|
|
|
### Developer data
|
|
|
|
my $secret_bcrypt = 'hola';
|
|
|
|
my $name = 'Larry';
|
|
|
|
my $surname = 'Wall';
|
|
|
|
my $email = 'larry@perl.org';
|
|
|
|
my $country = 'US';
|
|
|
|
my $verified = 0;
|
|
|
|
|
|
|
|
### Application data
|
|
|
|
my $app_name = 'Desfronificator';
|
|
|
|
my $app_description = 'Desfronifies the files.';
|
2022-03-16 17:05:10 +01:00
|
|
|
my $app_url = 'https://desfronificator.example.com';
|
2022-03-16 16:11:27 +01:00
|
|
|
my $app_price = '4.20';
|
2022-03-24 23:57:09 +01:00
|
|
|
my $app_git_repo =
|
|
|
|
'https://git.desfronificator.example.com/larry/desfronificator.git';
|
2022-03-16 16:11:27 +01:00
|
|
|
my $app_flatpak_builder_file =
|
|
|
|
'./resources/com.example.desfronificator.yml';
|
2022-03-24 23:57:09 +01:00
|
|
|
my $app_flatpak_repo =
|
|
|
|
'https://nightly.gnome.org/gnome-nightly.flatpakrepo';
|
2022-03-16 16:11:27 +01:00
|
|
|
my $app_verified = 0;
|
|
|
|
my $developer = Peace::Model::Developer->new(
|
|
|
|
secret_bcrypt => $secret_bcrypt,
|
|
|
|
name => $name,
|
|
|
|
surname => $surname,
|
|
|
|
email => $email,
|
|
|
|
country => $country,
|
|
|
|
verified => $verified,
|
|
|
|
);
|
2022-03-29 18:47:25 +02:00
|
|
|
my $app_id = 'com.example.desfronificator';
|
2022-03-16 16:11:27 +01:00
|
|
|
|
|
|
|
## WHEN
|
|
|
|
my $application = Peace::Model::Application->new(
|
|
|
|
developer => $developer,
|
2022-03-29 18:47:25 +02:00
|
|
|
app_id => $app_id,
|
2022-03-16 16:11:27 +01:00
|
|
|
name => $app_name,
|
|
|
|
description => $app_description,
|
|
|
|
url => $app_url,
|
|
|
|
price => $app_price,
|
|
|
|
flatpak_builder_file => $app_flatpak_builder_file,
|
2022-03-24 23:57:09 +01:00
|
|
|
flatpak_repo => $app_flatpak_repo,
|
2022-03-16 16:11:27 +01:00
|
|
|
verified => $app_verified,
|
2022-03-16 17:05:10 +01:00
|
|
|
git_repo => $app_git_repo,
|
2022-03-16 16:11:27 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
## THEN
|
|
|
|
ok $application->isa('Peace::Model::Application'),
|
|
|
|
'Application is made of application.';
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
## GIVEN
|
|
|
|
### Developer data
|
|
|
|
my $secret_bcrypt = 'hola';
|
|
|
|
my $name = 'Larry';
|
|
|
|
my $surname = 'Wall';
|
|
|
|
my $email = 'larry@perl.org';
|
|
|
|
my $country = 'US';
|
|
|
|
my $verified = 0;
|
|
|
|
|
|
|
|
### Application data
|
|
|
|
my $app_name = 'Desfronificator';
|
|
|
|
my $app_description = 'Desfronifies the files.';
|
|
|
|
my $app_url = 'desfronificator.example.com';
|
|
|
|
my $app_price = '4.20';
|
2022-03-24 23:57:09 +01:00
|
|
|
my $app_git_repo =
|
|
|
|
'https://git.desfronificator.example.com/larry/desfronificator.git';
|
2022-03-16 16:11:27 +01:00
|
|
|
my $app_flatpak_builder_file =
|
|
|
|
'./resources/com.example.desfronificator.yml';
|
2022-03-24 23:57:09 +01:00
|
|
|
my $app_flatpak_repo =
|
|
|
|
'https://nightly.gnome.org/gnome-nightly.flatpakrepo';
|
2022-03-16 16:11:27 +01:00
|
|
|
my $app_verified = 0;
|
|
|
|
my $dbh = DBI->connect( 'DBI:Mock:', '', '' );
|
|
|
|
my $developer = Peace::Model::Developer->new(
|
|
|
|
secret_bcrypt => $secret_bcrypt,
|
|
|
|
name => $name,
|
|
|
|
surname => $surname,
|
|
|
|
email => $email,
|
|
|
|
country => $country,
|
|
|
|
verified => $verified,
|
|
|
|
);
|
2022-03-29 18:47:25 +02:00
|
|
|
my $app_id = 'com.example.desfronificator';
|
2022-03-16 16:11:27 +01:00
|
|
|
|
|
|
|
my $developer_dao = Test::MockModule->new('Peace::DAO::Developer');
|
2022-03-16 16:13:44 +01:00
|
|
|
$developer_dao->mock(
|
|
|
|
recover_by_uuid => sub {
|
|
|
|
return $developer;
|
|
|
|
}
|
|
|
|
);
|
2022-03-16 16:11:27 +01:00
|
|
|
|
|
|
|
## WHEN
|
|
|
|
my $application = Peace::Model::Application->new(
|
2022-03-16 16:13:44 +01:00
|
|
|
developer_uuid => 'larryuuid',
|
2022-03-16 16:11:27 +01:00
|
|
|
name => $app_name,
|
|
|
|
description => $app_description,
|
|
|
|
url => $app_url,
|
|
|
|
price => $app_price,
|
|
|
|
flatpak_builder_file => $app_flatpak_builder_file,
|
2022-03-24 23:57:09 +01:00
|
|
|
flatpak_repo => $app_flatpak_repo,
|
2022-03-16 16:11:27 +01:00
|
|
|
verified => $app_verified,
|
2022-03-16 17:05:10 +01:00
|
|
|
git_repo => $app_git_repo,
|
2022-03-16 16:11:27 +01:00
|
|
|
dbh => $dbh,
|
2022-03-29 18:47:25 +02:00
|
|
|
app_id => $app_id,
|
2022-03-16 16:13:44 +01:00
|
|
|
);
|
2022-03-16 16:11:27 +01:00
|
|
|
|
2022-03-16 16:13:44 +01:00
|
|
|
## THEN
|
|
|
|
ok $application->isa('Peace::Model::Application');
|
|
|
|
ok $application->developer->isa('Peace::Model::Developer');
|
2022-03-16 16:11:27 +01:00
|
|
|
}
|