IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23875


Ignore:
Timestamp:
Apr 15, 2009, 11:32:16 AM (17 years ago)
Author:
jhoblitt
Message:

basic neb-ls tests

Location:
branches/neb_distrib_20081210/Nebulous
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/neb_distrib_20081210/Nebulous/bin/neb-ls

    r18092 r23875  
    11#!/usr/bin/env perl
    22
    3 # Copyright (C) 2007-2008  Joshua Hoblitt
    4 #
    5 # $Id: neb-ls,v 1.7 2008-06-12 20:03:37 jhoblitt Exp $
     3# Copyright (C) 2007-2009  Joshua Hoblitt
    64
    75use strict;
     
    97
    108use vars qw( $VERSION );
    11 $VERSION = '0.02';
     9$VERSION = '0.03';
    1210
    1311use Nebulous::Client;
     
    1614use Pod::Usage qw( pod2usage );
    1715
    18 my ($server, $long, $recursive);
     16my (
     17    $server,
     18    $long,
     19#    $recursive,
     20);
    1921
    2022$server = $ENV{'NEB_SERVER'} unless $server;
     
    2224GetOptions(
    2325    'server|s=s'    => \$server,
    24     'recursive|r'   => \$recursive,
     26#    'recursive|r'   => \$recursive,
    2527    'l|1'           => \$long,
    2628) || pod2usage( 2 );
     
    3941    unless defined $neb;
    4042
    41 # default to listing everything (bad idea?)
    42 $pattern ||= ".*";
     43# default to listing root
     44$pattern ||= "/";
    4345
    44 if ($recursive) {
    45     $pattern = "^" . $pattern . ".*";
    46 } else {
    47     $pattern = "^" . $pattern . "\$";
    48 }
     46#if ($recursive) {
     47#    $pattern = "^" . $pattern . ".*";
     48#} else {
     49#    $pattern = "^" . $pattern . "\$";
     50#}
    4951
    5052my $keys = $neb->find_objects($pattern);
     
    8688Optional
    8789
    88 =item * --recursive|-r
    89 
    90 By default C<neb-ls> will only try to match the exact string provided to it.
    91 With this option set all keys which match C<<pattern>> as a REGEX or substring
    92 will be returned.
    93 
    94 Optional
    95 
     90=cut
     91#=item * --recursive|-r
     92#
     93#By default C<neb-ls> will only try to match the exact string provided to it.
     94#With this option set all keys which match C<<pattern>> as a REGEX or substring
     95#will be returned.
     96#
     97#Optional
     98#
    9699=item * --server|-s <URL>
    97100
     
    130133=head1 COPYRIGHT
    131134
    132 Copyright (C) 2007-2008  Joshua Hoblitt.  All rights reserved.
     135Copyright (C) 2007-2009  Joshua Hoblitt.  All rights reserved.
    133136
    134137This program is free software; you can redistribute it and/or modify it under
  • branches/neb_distrib_20081210/Nebulous/t/70_neb-ls.t

    r23867 r23875  
    22
    33# Copyright (C) 2009  Joshua Hoblitt
    4 
    5 use strict;
    6 use warnings;
    7 
    8 use lib qw( ./lib ./t );
    9 
    10 use Test::Cmd;
    11 use Test::More tests => 3;
    124
    135=head1 NAME
     
    2113=cut
    2214
     15use strict;
     16use warnings;
     17
     18use Apache::Test qw( -withtestmore );
     19plan tests => 31;
     20
     21use lib qw( ./lib ./t );
     22
     23use Test::Cmd;
     24use Nebulous::Client;
     25use Test::Nebulous;
     26
     27my $hostport = Apache::Test->config->{ 'hostport' };
     28my $neb_url  = "http://$hostport/nebulous";
     29
     30
    2331my $cmd = 'bin/neb-ls';
    2432
     
    2634chmod 0755, 'bin/neb-ls';
    2735
    28 
    2936my $test = Test::Cmd->new(prog => $cmd, workdir => '');
    3037isa_ok($test, 'Test::Cmd');
    3138
     39# NEB_SERVER env var not set
     40Test::Nebulous->setup;
     41
    3242{
    3343    $test->run(args => '');
    3444    missing_args(2, "Required options: --server");
    3545}
     46
     47# NEB_SERVER set
     48Test::Nebulous->setup;
     49
     50{
     51    $ENV{NEB_SERVER} = $neb_url;
     52
     53    $test->run(args => '');
     54    is($? >> 8, 0, "exit code");
     55}
     56
     57Test::Nebulous->setup;
     58
     59{
     60    my $neb = Nebulous::Client->new(
     61        proxy => $neb_url,
     62    );
     63    $neb->create('foo');
     64
     65    $test->run(args => '');
     66
     67    is($? >> 8, 0, "exit code");
     68    like($test->stdout, qr/^foo$/,      "stdout");
     69    like($test->stderr, qr/^$/,         "stderr");
     70}
     71
     72Test::Nebulous->setup;
     73
     74{
     75    my $neb = Nebulous::Client->new(
     76        proxy => $neb_url,
     77    );
     78    $neb->create('foo');
     79    $neb->create('bar');
     80
     81    $test->run(args => '');
     82
     83    is($? >> 8, 0, "exit code");
     84    like($test->stdout, qr/^foo bar$/,  "stdout");
     85    like($test->stderr, qr/^$/,         "stderr");
     86}
     87
     88Test::Nebulous->setup;
     89
     90{
     91    my $neb = Nebulous::Client->new(
     92        proxy => $neb_url,
     93    );
     94    $neb->create('foo');
     95    $neb->create('bar');
     96
     97    $test->run(args => '-l');
     98
     99    is($? >> 8, 0, "exit code");
     100    like($test->stdout, qr/^foo\nbar\n$/,   "stdout");
     101    like($test->stderr, qr/^$/,             "stderr");
     102}
     103
     104Test::Nebulous->setup;
     105
     106{
     107    my $neb = Nebulous::Client->new(
     108        proxy => $neb_url,
     109    );
     110    $neb->create('foo');
     111    $neb->create('bar');
     112
     113    $test->run(args => '-1');
     114
     115    is($? >> 8, 0, "exit code");
     116    like($test->stdout, qr/^foo\nbar\n$/,   "stdout");
     117    like($test->stderr, qr/^$/,             "stderr");
     118}
     119
     120Test::Nebulous->setup;
     121
     122{
     123    my $neb = Nebulous::Client->new(
     124        proxy => $neb_url,
     125    );
     126    $neb->create('a/foo');
     127
     128    $test->run(args => '');
     129
     130    is($? >> 8, 0, "exit code");
     131    like($test->stdout, qr||,               "stdout");
     132    like($test->stderr, qr/^$/,             "stderr");
     133}
     134
     135Test::Nebulous->setup;
     136
     137{
     138    my $neb = Nebulous::Client->new(
     139        proxy => $neb_url,
     140    );
     141    $neb->create('a/foo');
     142
     143    $test->run(args => 'a');
     144
     145    is($? >> 8, 0, "exit code");
     146    like($test->stdout, qr|^a/foo$|,        "stdout");
     147    like($test->stderr, qr/^$/,             "stderr");
     148}
     149
     150Test::Nebulous->setup;
     151
     152{
     153    my $neb = Nebulous::Client->new(
     154        proxy => $neb_url,
     155    );
     156    $neb->create('a/foo');
     157    $neb->create('a/bar');
     158
     159    $test->run(args => 'a');
     160
     161    is($? >> 8, 0, "exit code");
     162    like($test->stdout, qr|^a/foo a/bar$|,  "stdout");
     163    like($test->stderr, qr/^$/,             "stderr");
     164}
     165
     166Test::Nebulous->setup;
     167
     168{
     169    my $neb = Nebulous::Client->new(
     170        proxy => $neb_url,
     171    );
     172    $neb->create('a/foo');
     173    $neb->create('foo');
     174
     175    $test->run(args => 'a');
     176
     177    is($? >> 8, 0, "exit code");
     178    like($test->stdout, qr|^a/foo$|,        "stdout");
     179    like($test->stderr, qr/^$/,             "stderr");
     180}
     181
     182Test::Nebulous->setup;
     183
     184{
     185    my $neb = Nebulous::Client->new(
     186        proxy => $neb_url,
     187    );
     188    $neb->create('a/foo');
     189    $neb->create('a/b/foo');
     190
     191    $test->run(args => 'a');
     192
     193    is($? >> 8, 0, "exit code");
     194    like($test->stdout, qr|^a/foo$|,        "stdout");
     195    like($test->stderr, qr/^$/,             "stderr");
     196}
     197
     198Test::Nebulous->cleanup;
    36199
    37200sub missing_args
Note: See TracChangeset for help on using the changeset viewer.