Colloquy-Data

 view release on metacpan or  search on metacpan

t/14test.t  view on Meta::CPAN

# $Id: 14test.t 528 2006-05-29 12:47:38Z nicolaw $

chdir('t') if -d 't';

use strict;
use Test::More;
eval "use Test::Deep";
if ($@) { plan skip_all => "Test::Deep required for testing parse_lin()"; }
else { plan tests => 3; }

use lib qw(./lib ../lib);
use Colloquy::Data qw(:all);

eval {
	for my $file (
		qw(users/jane users/john
		lists/vent lists/perl lists/girlsonly)
	  ) {
		chmod(0644, "data1.4/$file");
	}
};

my $data = _data();
cmp_deeply((users("data1.4"))[0], $data->{users}, "users()");
cmp_deeply((lists("data1.4"))[0], $data->{lists}, "lists()");

SKIP: {
	skip(  "Permissions test skipped for v1.15 or higher because of use of the Safe module",
		1)
	  if $Colloquy::Data::VERSION >= 1.15;

	eval {
		my $oldW = $^W;
		$^W = 0;
		chmod(0666, "data1.4/lists/girlsonly");
		my ($lists) = lists("data1.4");
		$^W = $oldW;
	};
	ok($@ =~ /insecure/, 'dies properly on insecure permissions');
}

sub _data {
	my $return = {
		'lists' => {
			'perl' => {  'owner'   => 'neech',
				'members' => [  'neech', 'zoe',    'goolies', 'tims',
					'pkent', 'botbot', 'milky',   'tomc',
					'flux'
				],
				'created'  => 'Sat Nov  5 22:04:49 2005',
				'flags'    => 'P',
				'masters'  => {},
				'listname' => 'perl',
				'used'     => 1132529518,
				'users'    => [ 'neech', 'zoe',    'goolies', 'tims',
					'pkent', 'botbot', 'milky',   'tomc',
					'flux'
				],
				'description' => 'For perl chat'
			},
			'girlsonly' => {
				'owner'   => 'jen',
				'members' => [  'neech', 'zoe',      'jen',    'becky',
					'sarah', 'heathers', 'botbot', 'neonkandi'
				],
				'created'  => 'Wed Nov  9 15:21:57 2005',
				'flags'    => 'PL',
				'masters'  => {},
				'listname' => 'GirlsOnly',
				'used'     => 1132857821,
				'users'    => [ 'neech', 'zoe',      'jen',    'becky',
					'sarah', 'heathers', 'botbot', 'neonkandi'
				],
				'description' => 'Just for girls.'
			},
			'vent' => {  'owner'   => 'heds',
				'members' => [  'neech', 'goolies', 'heathers', 'zoe',
					'bob',   'botbot',  'ricky',    'heds',
					'tims'
				],
				'created'  => 'Fri Nov 11 10:48:49 2005',
				'flags'    => 'P',
				'masters'  => {},
				'listname' => 'vent',
				'used'     => 1132957959,
				'users'    => [ 'neech', 'goolies', 'heathers', 'zoe',
					'bob',   'botbot',  'ricky',    'heds',
					'tims'
				],
				'description' => 'Moan moan moan moan moan'
			}
		},

		'users' => {
			'tims' => {'lists' => ['perl', 'vent']},



( run in 1.138 second using v1.01-cache-2.11-cpan-39bf76dae61 )