Commits

nuclon  committed d4bb09c

added skipping tests in case if there is no server at localhost

  • Participants
  • Parent commits c62063d

Comments (0)

Files changed (3)

 
 use_ok('Qless::Client');
 
-my $redis = Redis->new();
+SKIP: {
+	my $redis = eval { Redis->new() };
+	skip 'No Redis server at localhost', 5, $@;
 
-my $client = Qless::Client->new($redis);
+	my $client = Qless::Client->new($redis);
 
 # config
-my $config = $client->config;
-$config->set('application', 'qless');
-my $data = $config->get;
-is ref $data, 'HASH',                         'All options are got as hashref';
-is $data->{'application'}, 'qless',           'default "application" key is "qless"';
-is $config->get('application'), 'qless',      'default "application" key is "qless", v2';
-$config->set('application', 'qless-test');
-is $config->get('application'), 'qless-test', 'Setting new value works';
-$config->del('application');
-is $config->get('application'), 'qless',      'Deleting value works, got default value';
+	my $config = $client->config;
+	$config->set('application', 'qless');
+	my $data = $config->get;
+	is ref $data, 'HASH',                         'All options are got as hashref';
+	is $data->{'application'}, 'qless',           'default "application" key is "qless"';
+	is $config->get('application'), 'qless',      'default "application" key is "qless", v2';
+	$config->set('application', 'qless-test');
+	is $config->get('application'), 'qless-test', 'Setting new value works';
+	$config->del('application');
+	is $config->get('application'), 'qless',      'Deleting value works, got default value';
+}
 
 use_ok('Qless::Client');
 
-my $redis = Redis->new();
 
-my $client = Qless::Client->new($redis);
+SKIP: {
+	my $redis = eval { Redis->new() };
+	skip 'No Redis server at localhost', 1, $@;
 
-my $q = $client->queues('testing');
+	my $client = Qless::Client->new($redis);
 
-my $jid = $q->put('Qless::Job', {'test' => 'put_get'});
+	my $q = $client->queues('testing');
+
+	my $jid = $q->put('Test::Qless::Job', {'test' => 'put_get'});
 
 #warn $jid;
 
-my $job = $client->jobs($jid);
+	my $job = $client->jobs($jid);
 
-$job->track;
+	$job->track;
+
+
+	my $qjob = $q->pop;
+
+	warn Dumper($qjob);
+	$qjob->process;
+}
 
 #$job->tag('testtag');
 
 #warn Dumper($client->jobs->tracked);
+
+package Test::Qless::Job;
+use strict; use warnings;
+use Data::Dumper;
+
+sub process {
+	my ($self, $job) = @_;
+	warn "!!!!";
+}
+1;
 
 use_ok('Qless::Lua');
 
-my $redis = Redis->new();
+SKIP: {
+	my $redis = eval { Redis->new() };
+	skip 'No Redis server at localhost', 3, $@;
 
-my $script = Qless::Lua->new('config', $redis);
-is $script->([], 'get', 'heartbeat'), 60;
-is $script->([], 'get', 'application'), 'qless';
-is $script->reload, 'a5aa719f665348051a1ebb0d099f70177abea8e4', 'SHA checksum is correct';
+	my $script = Qless::Lua->new('config', $redis);
+	is $script->([], 'get', 'heartbeat'), 60;
+	is $script->([], 'get', 'application'), 'qless';
+	is $script->reload, 'a5aa719f665348051a1ebb0d099f70177abea8e4', 'SHA checksum is correct';
+}