App-Sv

 view release on metacpan or  search on metacpan

t/01-new.t  view on Meta::CPAN

#!perl

use strict;
use warnings;
use Test::More;
use Test::Deep;
use Test::Fatal;
use App::Sv;


subtest 'basic constructor' => sub {
	my $sm;

	is(exception { $sm = App::Sv->new({ run => { a => 'a' } }) },
		undef, 'new() lives with a simple command');
	ok($sm, '... got something back');
	is(ref($sm), 'App::Sv', '... of the proper type');
	cmp_deeply(
		$sm->{run}, 
		{
			a => {
				cmd => 'a',
				name => 'a',
				start_retries => 8,
				restart_delay => 1,
				start_wait => 1,
				stop_wait => 0,
				setsid => 1
			}
		},
		'... with the expected command list'
	);

	is(exception { $sm = App::Sv->new({ run => { a => [qw(a b c)] } }) },
		undef, 'new() lives with a simple array command');
	ok($sm, '... got something back');
	is(ref($sm), 'App::Sv', '... of the proper type');
	cmp_deeply(
		$sm->{run}, 
		{
			a => {
				cmd => ['a', 'b', 'c'],
				name => 'a',
				start_retries => 8,
				restart_delay => 1,
				start_wait => 1,
				stop_wait => 0,
				setsid => 1
			}
		},
		'... with the expected command list'
	);
	
	is(exception { $sm = App::Sv->new({
		run => { a => 'a', b => { cmd => 'b' } } }) },
		undef, 'new() lives with two commands, one simple, one complex');
	ok($sm, '... got something back');
	is(ref($sm), 'App::Sv', '... of the proper type');
	cmp_deeply($sm->{run},
		{
			a => {
				cmd => 'a',
				name => 'a',
				start_retries => 8,
				restart_delay => 1,
				start_wait => 1,
				stop_wait => 0,



( run in 1.365 second using v1.01-cache-2.11-cpan-54e63673c56 )