File: 001-subclass_cmd.t

package info (click to toggle)
libapp-nopaste-perl 1.013-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 456 kB
  • sloc: perl: 1,334; makefile: 2
file content (55 lines) | stat: -rw-r--r-- 1,073 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use strict;
use warnings;
use Test::More 0.88;
use Test::Deep;

{
    package App::Nopaste::Service::_MyTest;
    use parent 'App::Nopaste::Service';

    sub available { 1 }
    sub uri { 'test' }
    sub run {
        shift;
        my %a = @_;
        return (1, \%a);
    }
}

{
    package _MyTest::Cmd;
    use parent 'App::Nopaste::Command';

    sub read_text { 'test' }
}

cmp_deeply(
    [ App::Nopaste->plugins ],
    superbagof(
        map { 'App::Nopaste::Service::' . $_ }
            qw(Codepeek Debian Gist Mojopaste PastebinCom Pastie Shadowcat Snitch Ubuntu _MyTest ssh)
    ),
    'identified the service',
);

my $input = {
    desc => 'a test',
    nick => 'person',
    lang => 'text',
    services => ['App::Nopaste::Service::_MyTest'],
    extra_argv => []
};

my $cmd = _MyTest::Cmd->new($input);
isa_ok($cmd,'App::Nopaste::Command');

my $ret = $cmd->run;
ok(ref($ret) eq 'HASH') or diag $ret;

is($ret->{nick}, $input->{nick});
is($ret->{lang}, $input->{lang});
is($ret->{services}, $input->{services});
is($ret->{text},'test');

done_testing;