File: release-41-transport_middle_of_line_prompt_match.t

package info (click to toggle)
libnet-cli-interact-perl 2.400002-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 576 kB
  • sloc: perl: 2,075; makefile: 7
file content (42 lines) | stat: -rw-r--r-- 1,093 bytes parent folder | download
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
#!/usr/bin/perl

BEGIN {
  unless ($ENV{RELEASE_TESTING}) {
    require Test::More;
    Test::More::plan(skip_all => 'these tests are for release candidate testing');
  }
}

{
    package # hide from pause
        Net::CLI::Interact::Transport::LoopbackMiddleOfLinePrompt;

    use Moo;
    extends 'Net::CLI::Interact::Transport::Loopback';

    sub runtime_options {
        return ('-ne', 'BEGIN { $| = 1 }; use Time::HiRes qw( sleep ); print "some line\n looks-like-prompt#"; sleep(0.01); print "additional-characters\nPROMPT#";');
    }
}

use strict; use warnings FATAL => 'all';
use Test::More 0.88;
use Test::File::ShareDir::Dist { "Net-CLI-Interact" => "share" };

use Net::CLI::Interact;

my $s = new_ok('Net::CLI::Interact' => [{
    transport => 'LoopbackMiddleOfLinePrompt',
    personality => 'ios',
}]);

# uncomment for debugging
# $s->set_global_log_at('debug');

$s->set_prompt('privileged');

my $out = $s->cmd('show running-config');
is($out, "some line\n looks-like-prompt#additional-characters\n", 'full response returned');
is($s->last_prompt, 'PROMPT#');

done_testing;