Permalink
Browse files

* connect to server in new method

* test against private server only
  • Loading branch information...
1 parent 20bdfc8 commit 927143f10de3cf228852be81c1c34777ea275e40 @cofyc committed Sep 6, 2012
Showing with 22 additions and 67 deletions.
  1. +4 −2 lib/Redis.pm
  2. +0 −34 t/00-basic.t
  3. +1 −4 t/01-connect.t
  4. +3 −3 t/02-connection.t
  5. +1 −1 t/02-hashes.t
  6. +1 −1 t/02-keys.t
  7. +1 −2 t/02-lists.t
  8. +1 −2 t/02-pub&sub.t
  9. +1 −2 t/02-scripting.t
  10. +1 −2 t/02-server.t
  11. +1 −2 t/02-sets.t
  12. +1 −2 t/02-sortedsets.t
  13. +1 −2 t/02-strings.t
  14. +1 −2 t/02-transactions.t
  15. +1 −2 t/03-binary.t
  16. +1 −2 t/03-multibytes.t
  17. +1 −2 t/04-exec-any-commands.t
  18. +1 −0 t/redis.conf
View
6 lib/Redis.pm
@@ -87,10 +87,12 @@ method new(Str $server?, Str :$encoding?, Bool :$decode_response?) {
if $decode_response.defined {
%config<decode_response> = $decode_response;
}
- return self.bless(*, |%config);
+ my $obj = self.bless(*, |%config);
+ $obj.reconnect;
+ return $obj;
}
-method connect {
+method reconnect {
if $.sock.defined {
die "Sorry, connecting via unix sock is currently unsupported!";
} else {
View
34 t/00-basic.t
@@ -1,34 +0,0 @@
-use v6;
-
-BEGIN { @*INC.push('t', 'lib') };
-use Redis;
-use Test;
-
-my @new_tasks =
- \() => {
- 'host' => '127.0.0.1',
- 'port' => 6379,
- }
- , \('192.168.0.1') => {
- 'host' => '192.168.0.1',
- 'port' => 6379,
- }
- , \('192.168.0.1:6379') => {
- 'host' => '192.168.0.1',
- 'port' => 6379,
- }
- , \('/path/to/redis.sock') => {
- 'sock' => '/path/to/redis.sock',
- }
- ;
-
-plan [+] @new_tasks.map({ $_.value.elems });
-
-for @new_tasks -> $p {
- my $r = Redis.new(|$p.key);
- $p.value.map({
- is_deeply $r."{.key}"(), .value;
- });
-}
-
-# vim: ft=perl6
View
5 t/01-connect.t
@@ -6,9 +6,6 @@ use Test;
plan 1;
-{
- my $r = Redis.new('127.0.0.1:0');
- dies_ok { $r.connect }
-}
+dies_ok { Redis.new('127.0.0.1:0') }
# vim: ft=perl6
View
6 t/02-connection.t
@@ -5,11 +5,11 @@ use Redis;
use Test;
my $r = Redis.new("127.0.0.1:63790", decode_response => True);
-$r.connect;
+$r.auth('20bdfc8e73365b2fde82d7b17c3e429a9a94c5c9');
-plan 5;
+plan 4;
-dies_ok { $r.auth("WRONG PASSWORD"); }
+#dies_ok { $r.auth("WRONG PASSWORD"); }
is_deeply $r.echo("Hello World!"), "Hello World!";
is_deeply $r.ping, True;
is_deeply $r.select(2), True;
View
2 t/02-hashes.t
@@ -5,7 +5,7 @@ use Redis;
use Test;
my $r = Redis.new("127.0.0.1:63790", decode_response => True);
-$r.connect;
+$r.auth('20bdfc8e73365b2fde82d7b17c3e429a9a94c5c9');
$r.flushall;
if $r.info<redis_version> gt "2.6" {
View
2 t/02-keys.t
@@ -5,7 +5,7 @@ use Redis;
use Test;
my $r = Redis.new("127.0.0.1:63790", decode_response => True);
-$r.connect;
+$r.auth('20bdfc8e73365b2fde82d7b17c3e429a9a94c5c9');
$r.flushall;
View
3 t/02-lists.t
@@ -3,10 +3,9 @@ use v6;
BEGIN { @*INC.push('t', 'lib') };
use Redis;
use Test;
-use Test::SpawnRedisServer;
my $r = Redis.new("127.0.0.1:63790", decode_response => True);
-$r.connect;
+$r.auth('20bdfc8e73365b2fde82d7b17c3e429a9a94c5c9');
$r.flushall;
plan 16;
View
3 t/02-pub&sub.t
@@ -3,10 +3,9 @@ use v6;
BEGIN { @*INC.push('t', 'lib') };
use Redis;
use Test;
-use Test::SpawnRedisServer;
my $r = Redis.new("127.0.0.1:63790", decode_response => True);
-$r.connect;
+$r.auth('20bdfc8e73365b2fde82d7b17c3e429a9a94c5c9');
$r.flushall;
plan 1;
View
3 t/02-scripting.t
@@ -3,10 +3,9 @@ use v6;
BEGIN { @*INC.push('t', 'lib') };
use Redis;
use Test;
-use Test::SpawnRedisServer;
my $r = Redis.new("127.0.0.1:63790", decode_response => True);
-$r.connect;
+$r.auth('20bdfc8e73365b2fde82d7b17c3e429a9a94c5c9');
$r.flushall;
if $r.info<redis_version> gt "2.6" {
View
3 t/02-server.t
@@ -3,10 +3,9 @@ use v6;
BEGIN { @*INC.push('t', 'lib') };
use Redis;
use Test;
-use Test::SpawnRedisServer;
my $r = Redis.new("127.0.0.1:63790", decode_response => True);
-$r.connect;
+$r.auth('20bdfc8e73365b2fde82d7b17c3e429a9a94c5c9');
plan 3;
View
3 t/02-sets.t
@@ -3,10 +3,9 @@ use v6;
BEGIN { @*INC.push('t', 'lib') };
use Redis;
use Test;
-use Test::SpawnRedisServer;
my $r = Redis.new("127.0.0.1:63790", decode_response => True);
-$r.connect;
+$r.auth('20bdfc8e73365b2fde82d7b17c3e429a9a94c5c9');
$r.flushall;
plan 15;
View
3 t/02-sortedsets.t
@@ -3,10 +3,9 @@ use v6;
BEGIN { @*INC.push('t', 'lib') };
use Redis;
use Test;
-use Test::SpawnRedisServer;
my $r = Redis.new("127.0.0.1:63790", decode_response => True);
-$r.connect;
+$r.auth('20bdfc8e73365b2fde82d7b17c3e429a9a94c5c9');
$r.flushall;
plan 23;
View
3 t/02-strings.t
@@ -3,10 +3,9 @@ use v6;
BEGIN { @*INC.push('t', 'lib') };
use Redis;
use Test;
-use Test::SpawnRedisServer;
my $r = Redis.new("127.0.0.1:63790", decode_response => True);
-$r.connect;
+$r.auth('20bdfc8e73365b2fde82d7b17c3e429a9a94c5c9');
$r.flushall;
if $r.info<redis_version> gt "2.6" {
View
3 t/02-transactions.t
@@ -3,10 +3,9 @@ use v6;
BEGIN { @*INC.push('t', 'lib') };
use Redis;
use Test;
-use Test::SpawnRedisServer;
my $r = Redis.new("127.0.0.1:63790", decode_response => True);
-$r.connect;
+$r.auth('20bdfc8e73365b2fde82d7b17c3e429a9a94c5c9');
$r.flushall;
plan 5;
View
3 t/03-binary.t
@@ -3,10 +3,9 @@ use v6;
BEGIN { @*INC.push('t', 'lib') };
use Redis;
use Test;
-use Test::SpawnRedisServer;
my $r = Redis.new("127.0.0.1:63790");
-$r.connect;
+$r.auth('20bdfc8e73365b2fde82d7b17c3e429a9a94c5c9');
$r.flushall;
plan 2;
View
3 t/03-multibytes.t
@@ -3,10 +3,9 @@ use v6;
BEGIN { @*INC.push('t', 'lib') };
use Redis;
use Test;
-use Test::SpawnRedisServer;
my $r = Redis.new("127.0.0.1:63790", decode_response => True);
-$r.connect;
+$r.auth('20bdfc8e73365b2fde82d7b17c3e429a9a94c5c9');
$r.flushall;
plan 1;
View
3 t/04-exec-any-commands.t
@@ -3,10 +3,9 @@ use v6;
BEGIN { @*INC.push('t', 'lib') };
use Redis;
use Test;
-use Test::SpawnRedisServer;
my $r = Redis.new("127.0.0.1:63790", decode_response => True);
-$r.connect;
+$r.auth('20bdfc8e73365b2fde82d7b17c3e429a9a94c5c9');
plan 1;
View
1 t/redis.conf
@@ -3,3 +3,4 @@ appendonly no
daemonize no
port 63790
bind 127.0.0.1
+requirepass 20bdfc8e73365b2fde82d7b17c3e429a9a94c5c9

0 comments on commit 927143f

Please sign in to comment.