?
Current Path : /opt/PUC/t/ |
Linux gator3171.hostgator.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 |
Current File : //opt/PUC/t/02-WebApp.t |
#!/usr/bin/env perl use strict; use warnings; use FindBin; use Test::More; use Test::Exception; if ( use_ok('PUC::Collector') and use_ok('PUC::Module::WebApp') ) { my $app_config; my $domains; subtest 'Get PUC::Collector config' => sub { my $bindir = $FindBin::Bin . '/..'; my $debug = $ENV{TEST_VERBOSE} || 0; my $dryrun = 1; my $dataroot = $FindBin::Bin . '/../testdata/'; lives_ok { $app_config = PUC::Collector::parse_config( bindir => $bindir, debug => $debug, dryrun => $dryrun, dataroot => $dataroot, ); } 'Lives through parsing PUC::Collector config'; lives_ok { $domains = PUC::Collector::get_domain_list($app_config); } ' Lives through getting domains'; }; if ($app_config) { subtest 'new' => sub { my $module; lives_ok { $module = PUC::Module::WebApp->new( app_config => $app_config ); } 'Lives through init'; cmp_ok( scalar( keys %{ $module->{webapps} } ), '==', 4, 'Found 4 webapp definitions' ); }; # find_web_app will fail if init failed. subtest 'find_web_app - should find wordpress' => sub { for my $domain ( @{$domains} ) { if ( $domain->{docroot} =~ /add.osshareddec4.com/ ) { my $result; lives_ok { $result = PUC::Module::WebApp->new($app_config) ->find_web_app( $domain, 'wordpress' ); } 'Lives through finding wordpress'; if ( cmp_ok( ref($result), 'eq', 'HASH', 'Got a hash' ) ) { cmp_ok( $result->{webApp}->{name}, 'eq', 'wordpress', 'found wordpress' ); } } } }; } } done_testing;