Created
January 14, 2010 01:37
-
-
Save afeinberg/276773 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use strict; | |
use warnings; | |
use Test::More qw( no_plan ); | |
BEGIN { | |
use File::Basename; | |
use File::Spec; | |
use lib File::Spec->catfile( dirname( __FILE__ ), '..', 'lib' ); | |
use_ok( 'Ca20::Container::XML' ); | |
} | |
my $cxml = Ca20::Container::XML->new | |
( dir => | |
File::Spec->catfile( dirname(__FILE__), | |
'sample_containers' ) ); | |
# Simple queries, not using the grammar | |
my $res = $cxml->query_container("container_1::description"); | |
ok ( $res->[0] eq 'Web servers out in the east.', 'Got a static string correctly' ); | |
my $res2 = $cxml->query_container("container_1::ALL"); | |
ok (($res2->[0] eq 'www01.east.example.com' and | |
$res2->[1] eq 'www02.east.example.com' and | |
$res2->[2] eq 'www03.east.example.com'), "Got the ALL query expanded correctly" ); | |
my $res3 = $cxml->query_container("container_1"); | |
ok (($res3->[0] eq 'www01.east.example.com' and | |
$res3->[1] eq 'www02.east.example.com' and | |
$res3->[2] eq 'www03.east.example.com'), "Got the default query expanded correctly" ); | |
my $res4 = $cxml->query_container("container_2"); | |
ok (($res4->[0] eq 'www10.west.example.com' and | |
$res4->[1] eq 'www11.west.example.com' and | |
$res4->[2] eq 'www01.west.example.com' and | |
$res4->[3] eq 'www02.west.example.com'), "Got a reference in XML file expanded correctly"); | |
ok ([$cxml->expand("foo")]->[0] eq "foo", "Expanding a string gets a string"); | |
#@$cxml->query_container("container_3"); | |
my @res5 = $cxml->expand("foo,bar"); | |
ok (($res5[0] eq "foo" and | |
$res5[1] eq "bar"), "Expanding a list gets an aref"); | |
my ($res6) = $cxml->expand("/container_1::description"); | |
ok ($res6->[0] eq "Web servers out in the east.", "Expanded ok /container_1::description"); | |
# This is not yet working in fully automated for more than one cluster | |
my ($res7) = $cxml->expand('/[/container_3]'); | |
ok (($res7->[0] eq 'www01.west.example.com' and | |
$res7->[4] eq 'www03.east.example.com'), "Recursive queries work"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment