From 440c75037df939463fc7cc38cbec39b78a221f19 Mon Sep 17 00:00:00 2001 From: Ryan Voots Date: Fri, 30 Oct 2020 18:16:40 -0700 Subject: [PATCH] Fill out more mock said object, the rest of the plugins need more complete support --- t/arg-plugin.t | 23 +++++++++++++++++++++++ t/echo-plugin.t | 16 ++++++++++++++++ t/lib/t/common.pm | 11 +++++++++++ 3 files changed, 50 insertions(+) create mode 100644 t/arg-plugin.t create mode 100644 t/echo-plugin.t diff --git a/t/arg-plugin.t b/t/arg-plugin.t new file mode 100644 index 0000000..4ecaca6 --- /dev/null +++ b/t/arg-plugin.t @@ -0,0 +1,23 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use utf8; +use Test::More; +use lib::relative './lib', '../lib', '..'; +use t::simple_plugin; +use Encode qw/encode/; + +load_plugin("arg"); + +check("n", "perlbot", [1], "empty but valid"); + +check("a", "a", [1], "macro args"); # this one is difficult to test for, it really gets the arguments to the parent macro +check("", "", [1], "empty arguments, needs better check"); + +check("h", "irc.client.example.com", [1], "host"); +check("c", "##NULL", [1], "channel"); +check("o", 0, [1], "is op?"); +check("s", "irc.server.example.com", [1], "server"); + +done_testing(); diff --git a/t/echo-plugin.t b/t/echo-plugin.t new file mode 100644 index 0000000..fabc036 --- /dev/null +++ b/t/echo-plugin.t @@ -0,0 +1,16 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use utf8; +use Test::More; +use lib::relative './lib', '../lib', '..'; +use t::simple_plugin; +use Encode qw/encode/; + +load_plugin("echo"); + +check("", "", [1], "empty but valid"); +check("Hello World", "Hello World", [1], "HW"); +check("\N{SNOWMAN}", encode("utf8", "\N{SNOWMAN}"), [1], "Encoding correctly"); +done_testing(); diff --git a/t/lib/t/common.pm b/t/lib/t/common.pm index a334f7a..7dcfe63 100644 --- a/t/lib/t/common.pm +++ b/t/lib/t/common.pm @@ -25,10 +25,21 @@ sub make_said # TODO make this fill out a lot more of the said object + $who //= "perlbot"; + my @args = split /\s+/, $body; my $said = { body => $body, recommended_args => \@args, + macro_args => $body, + name => $who, + ircname => $who."irc", + host => "irc.client.example.com", + sender_raw => "", # this never gets filled out + channel => $channel // "##NULL", + server => $server // "irc.server.example.com", + by_chan_op => 0, + captured => "", }; }