?
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/01-puc-collector.t |
#!/usr/bin/env perl use strict; use warnings; use FindBin; use Test::More; use Test::Exception; if ( use_ok('PUC::Collector') ) { subtest 'runs with test data' => sub { my $bindir = $FindBin::Bin . '/..'; my $debug = $ENV{TEST_VERBOSE} || 0; my $dryrun = 1; my $single_domain; my $single_user; my $dataroot = $FindBin::Bin . '/../testdata/'; my $datastore_url = "dryrun://localhost"; my $datastore_key_file = $dataroot . "etc/collector/puc_datastore_api_key"; lives_ok { PUC::Collector::run( bindir => $bindir, debug => $debug, dryrun => $dryrun, single_domain => $single_domain, single_user => $single_user, dataroot => $dataroot, datastore_url => $datastore_url, datastore_key_file => $datastore_key_file, ); } 'Lives through run'; }; subtest 'get_domain_list' => sub { my $config = { dataroot => $FindBin::Bin . '/../testdata/' }; my $domains; lives_ok { $domains = PUC::Collector::get_domain_list($config); } ' Lives through getting domains'; cmp_ok( scalar( @{$domains} ), '==', 5, 'Found 5 domains' ); }; subtest 'parse_config' => sub { my $bindir = $FindBin::Bin . '/..'; my $debug = $ENV{TEST_VERBOSE} || 0; my $dryrun = 1; my $dataroot = $FindBin::Bin . '/../../testdata/'; my $config; lives_ok { $config = PUC::Collector::parse_config( bindir => $bindir, debug => $debug, dryrun => $dryrun, dataroot => $dataroot, ); } 'Lives through parsing config'; if ( cmp_ok( ref($config), 'eq', 'HASH', 'Got back a config hash' ) ) { my $found_webapp = grep { $_ eq 'WebApp' } @{ $config->{primary_modules} }; cmp_ok( $found_webapp, '==', 1, 'Found the webapp module' ); } }; } done_testing;