4 use Test::More tests => 25;
8 use_ok('MooseX::Daemonize::Pid::File');
12 my $f = MooseX::Daemonize::Pid::File->new(
13 file => [ 't', 'foo.pid' ]
15 isa_ok($f, 'MooseX::Daemonize::Pid::File');
17 isa_ok($f->file, 'Path::Class::File');
19 is($f->pid, $$, '... the PID is our current process');
22 exception { $f->write },
24 '... writing the PID file',
27 is($f->file->slurp(chomp => 1), $f->pid, '... the PID in the file is correct');
29 ok($f->is_running, '... it is running too');
32 exception { $f->remove },
34 '... removing the PID file',
37 ok(!-e $f->file, '... the PID file does not exist anymore');
41 my $f = MooseX::Daemonize::Pid::File->new(
42 file => [ 't', 'bar.pid' ]
44 isa_ok($f, 'MooseX::Daemonize::Pid::File');
46 isa_ok($f->file, 'Path::Class::File');
49 exception { $f->write },
51 '... writing the PID file',
54 is($f->file->slurp(chomp => 1), $f->pid, '... the PID in the file is correct');
55 is($f->pid, $$, '... the PID is our current process');
57 ok($f->is_running, '... it is running too');
60 exception { $f->remove },
62 '... removing the PID file',
65 ok(!-e $f->file, '... the PID file does not exist anymore');
71 my $f = MooseX::Daemonize::Pid::File->new(
72 file => [ 't', 'baz.pid' ],
75 isa_ok($f, 'MooseX::Daemonize::Pid::File');
77 isa_ok($f->file, 'Path::Class::File');
79 is($f->pid, $PID, '... the PID is our made up PID');
82 exception { $f->write },
84 '... writing the PID file',
87 is($f->file->slurp(chomp => 1), $f->pid, '... the PID in the file is correct');
89 ok(!$f->is_running, '... it is not running (cause we made the PID up)');
92 exception { $f->remove },
94 '... removing the PID file',
97 ok(!-e $f->file, '... the PID file does not exist anymore');