@@ -7,17 +7,14 @@ use strict;
77use FindBin;
88use lib " $FindBin::Bin /mocks" ;
99use File::Path ();
10+ use File::Temp ();
1011
1112use Test::More tests => 42;
1213use cPanel::TaskQueue;
1314
14- my $tmpdir = ' ./tmp ' ;
15+ my $tmpdir = File::Temp -> newdir() ;
1516my $statedir = " $tmpdir /state_test" ;
1617
17- # In case the last test did not succeed.
18- cleanup();
19- File::Path::mkpath($tmpdir ) or die " Unable to create tmpdir: $! " ;
20-
2118# Create the real TaskQueue
2219my $queue = cPanel::TaskQueue-> new( { name => ' tasks' , state_dir => $statedir } );
2320isa_ok( $queue , ' cPanel::TaskQueue' , ' Correct object built.' );
@@ -58,10 +55,10 @@ ok( !$queue->queue_task("noop a b c"), 'cannot queue a duplicate command' );
5855# Look at first task
5956my $task = $queue -> peek_next_task();
6057isa_ok( $task , ' cPanel::TaskQueue::Task' , ' We have a task' );
61- is( $task -> command(), ' noop' , ' Correct command in the queue.' );
62- is( join ( ' ' , $task -> args() ), ' a b c' , ' Correct command arguments.' );
63- is( $task -> argstring(), ' a b c' , ' Correct command argument string.' );
64- is( $task -> uuid(), $qid2 , ' Correct Task id.' );
58+ is( $task -> command(), ' noop' , ' Correct command in the queue.' );
59+ is( join ( ' ' , $task -> args() ), ' a b c' , ' Correct command arguments.' );
60+ is( $task -> argstring(), ' a b c' , ' Correct command argument string.' );
61+ is( $task -> uuid(), $qid2 , ' Correct Task id.' );
6562
6663# Test a second TaskQueue on same file.
6764my $q2 = cPanel::TaskQueue-> new( { name => ' tasks' , state_dir => $statedir } );
@@ -104,10 +101,3 @@ like( $@, qr/No Task uuid/, 'Can not check processing task without a uuid' );
104101
105102eval { $queue -> is_task_processing(1111111); };
106103like( $@ , qr / No Task uuid/ , ' Can not check processing task with an invalid uuid' );
107-
108- cleanup();
109-
110- # Clean up after myself
111- sub cleanup {
112- File::Path::rmtree($tmpdir );
113- }
0 commit comments