IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 16232


Ignore:
Timestamp:
Jan 25, 2008, 10:54:04 AM (18 years ago)
Author:
jhoblitt
Message:

define Nebulous::Client::find_objects() as returning [] when NO keys are found

Location:
trunk/Nebulous
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous/bin/neb-touch

    r16225 r16232  
    33# Copyright (C) 2007-2008  Joshua Hoblitt
    44#
    5 # $Id: neb-touch,v 1.6 2008-01-25 02:44:49 jhoblitt Exp $
     5# $Id: neb-touch,v 1.7 2008-01-25 20:54:04 jhoblitt Exp $
    66
    77use strict;
     
    4040    unless defined $neb;
    4141
    42 
    43 unless ($neb->find_objects($file)) {
    44     $neb->create($file, $volume)
    45         or die "failed to create Nebulous key $file";
     42unless (scalar @{$neb->find_objects($file)}) {
     43    if (defined $volume) {
     44        $neb->create($file, $volume)
     45            or die "failed to create Nebulous key $file";
     46    } else {
     47        $neb->create($file)
     48            or die "failed to create Nebulous key $file";
     49    }
    4650}
    4751
  • trunk/Nebulous/lib/Nebulous/Client.pm

    r16227 r16232  
    11# Copyright (c) 2004  Joshua Hoblitt
    22#
    3 # $Id: Client.pm,v 1.37 2008-01-25 02:54:53 jhoblitt Exp $
     3# $Id: Client.pm,v 1.38 2008-01-25 20:54:04 jhoblitt Exp $
    44
    55package Nebulous::Client;
     
    420420    $log->debug( "leaving" );
    421421
    422 # aparently empty arrays are being turned into undef by SOAP::Lite so the
    423 # behavior of this function is different then it's ::Server counter part
    424 
    425     return scalar @$keys ? $keys : undef;
     422# note that no keys found is returned as []
     423
     424    return $keys;
    426425}
    427426
  • trunk/Nebulous/t/64_client_find_objects.t

    r13048 r16232  
    33# Copryight (C) 2004-2005  Joshua Hoblitt
    44#
    5 # $Id: 64_client_find_objects.t,v 1.1 2007-04-27 00:09:22 jhoblitt Exp $
     5# $Id: 64_client_find_objects.t,v 1.2 2008-01-25 20:54:04 jhoblitt Exp $
    66
    77use strict;
     
    1010use Apache::Test qw( -withtestmore );
    1111
    12 plan tests => 6;
     12plan tests => 7;
    1313
    1414use lib qw( ./t ./lib );
     
    3131    my $keys = $neb->find_objects();
    3232
    33     is($keys, undef, 'number of keys found');
     33    # undef indicates an error
     34    is($keys, undef, 'undef is an error');
    3435}
    3536
     
    6768Test::Nebulous->setup;
    6869
     70{
     71    # key does not exist
     72    my $neb = Nebulous::Client->new(
     73        proxy => "http://$hostport/nebulous",
     74    );
     75
     76    my $keys = $neb->find_objects( "bar" );
     77
     78    is_deeply($keys, [], 'number of keys found');
     79}
     80
     81Test::Nebulous->setup;
     82
    6983eval {
    7084    my $neb = Nebulous::Client->new(
Note: See TracChangeset for help on using the changeset viewer.