Cisco-Reconfig

 view release on metacpan or  search on metacpan

t/classmap-12-4.t  view on Meta::CPAN

#!/usr/bin/perl -I. -w

#
# The configuration file in this test is buggy.  It's a Cisco
# bug so we'll try to work around it.
#

use Cisco::Reconfig;
use Test::More qw(no_plan);
use Carp qw(verbose);
use Scalar::Util qw(weaken);

my $debugdump = 0;

my $config = readconfig(\*DATA);

my $finished;

END { ok($finished, "finished") }

if ($debugdump) {
	no warnings;
	require FindBin;
	require YAML;
	require Data::Dumper;
	require File::Slurp;
	require "$FindBin::Bin/lib/Local/NoWeak.pm";
	local($Data::Dumper::Indent) = 1;
	my $strong_only = Local::NoWeak::strong_clone($config);
	File::Slurp::write_file("output.yaml", YAML::Dump($strong_only));
	File::Slurp::write_file("output.dd", Data::Dumper::Dumper($strong_only));
	exit(0);
}

ok(defined $config);

BAIL_OUT("parse failed") unless defined $config;

is($config->get('set-dscp-transmit 63')->alltext, <<END, 'get set-dscp-transmit 63');
set-dscp-transmit 63
  bandwidth 8
  random-detect
  random-detect exponential-weighting-constant 3
  random-detect precedence 6   20    32    10   
 class ce_ef_output
   police 40000 2000 2000 conform-action set-dscp-transmit ef exceed-action
END

is($config->get('exceed-action set-dscp-transmit af31')->alltext, <<END, 'get exceed-action set-dscp-transmit af31');
exceed-action set-dscp-transmit af31 violate-action set-dscp-transmit af32
  bandwidth 180
  random-detect dscp-based
  random-detect exponential-weighting-constant 3
  random-detect dscp 26   20    32    10   
  random-detect dscp 28   6     16    5    
 class class-default
  bandwidth 26
  random-detect
  random-detect exponential-weighting-constant 3
  random-detect precedence 0   12    32    5    
  random-detect precedence 1   12    32    5    
  random-detect precedence 2   12    32    5    
  random-detect precedence 3   12    32    5    
  random-detect precedence 4   12    32    5    
  random-detect precedence 5   12    32    5    
  random-detect precedence 6   40    64    10   
  random-detect precedence 7   12    32    5    
END

ok(! $config->get('exceed-action set-xyzds-transmit af31'), 'get line not in the file');
is($config->get('exceed-action set-xyzds-transmit af31')->text, '', 'get line not in the file text');



( run in 1.003 second using v1.01-cache-2.11-cpan-5a3173703d6 )