aboutsummaryrefslogtreecommitdiff
path: root/test/test_ping.t
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_ping.t')
-rwxr-xr-xtest/test_ping.t46
1 files changed, 20 insertions, 26 deletions
diff --git a/test/test_ping.t b/test/test_ping.t
index f7ae60f..c31c538 100755
--- a/test/test_ping.t
+++ b/test/test_ping.t
@@ -2,33 +2,27 @@
use strict;
use warnings;
-
use Test::Simple tests => 2;
+use Mock::CommandRegistry;
use Plugin::Ping;
-our $registered;
-our $response;
-my $expected = "user: pong";
-
-sub register_cmd {
- my ($module, $name, $run) = @_;
-
- $registered = 1;
-
- $response = $run->(
- undef, # irc
- undef, # logger
- 'user!who@example.com',
- undef, # where
- undef, # ided
- undef, # rest
- undef, # no reenter
- undef, # arguments
- );
-}
-
-Plugin::Ping->configure(\&register_cmd, undef, undef, undef);
-
-ok($registered, "plugin registered command");
-ok($response eq $expected, "echo expectation met");
+my $cr = new Mock::CommandRegistry;
+my $register = sub { $cr->register(@_); };
+Plugin::Ping->configure($register, undef, undef, undef);
+ok($cr->is_registered_to_owner("Plugin::Ping", "ping"), "registered command");
+
+my $pinger = "somelad";
+my %ctx = (
+ irc => undef,
+ logger => undef,
+ who => "$pinger!who\@example.com",
+ where => undef,
+ ided => undef,
+ rest => undef,
+ no_reenter => undef,
+ args => undef
+);
+my $expected = "$pinger: pong";
+my $response = $cr->run_owned("Plugin::Ping", "ping", %ctx);
+ok($response eq $expected, "pong format correct");