[go: up one dir, main page]

File: host.t

package info (click to toggle)
rex 1.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,800 kB
  • sloc: perl: 30,667; xml: 264; makefile: 8
file content (28 lines) | stat: -rw-r--r-- 997 bytes parent folder | download | duplicates (2)
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
use strict;
use warnings;

use Test::More tests => 10;

use Rex::Commands::Host;

my @content = eval { local (@ARGV) = ("t/hosts.ex"); <>; };
my @ret = Rex::Commands::Host::_parse_hosts(@content);

is( $ret[0]->{host}, "localhost", "got localhost" );
is( $ret[0]->{ip},   "127.0.0.1", "got 127.0.0.1" );

@ret = get_host( "mango", @content );
is( $ret[0]->{ip},   "192.168.2.23",     "got 192.168.2.23 by alias" );
is( $ret[0]->{host}, "mango.rexify.org", "got mango.rexify.org by alias" );

@content = eval { local (@ARGV) = ("t/hosts.ex2"); <>; };
@ret = Rex::Commands::Host::_parse_hosts(@content);

is( $ret[0]->{host}, "localhost",  "got localhost" );
is( $ret[0]->{ip},   "127.0.0.1",  "got 127.0.0.1" );
is( $ret[2]->{host}, "rexify.org", "got rexify.org" );
is( $ret[2]->{ip},   "1.2.3.4",    "got 1.2.3.4" );

@ret = get_host( "rexify.org", @content );
is( $ret[0]->{ip},   "1.2.3.4",    "got 1.2.3.4 from get_host" );
is( $ret[0]->{host}, "rexify.org", "got rexify.org from get_host" );