IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 27, 2019, 12:04:14 PM (7 years ago)
Author:
eugene
Message:

merging updates to Nebulous from EAM dev branch ipp-20191011

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous/t/59_client_delete.t

    r24440 r41172  
    1010use Apache::Test qw( -withtestmore );
    1111
    12 plan tests => 13;
     12plan tests => 18;
    1313
    1414use lib qw( ./t ./lib );
     
    2020my $hostport = Apache::Test->config->{ 'hostport' };
    2121
    22 Test::Nebulous->setup;
    23 
     22# ensure fresh start:
     23Test::Nebulous->setup;
     24Test::Nebulous->cleanup;
     25
     26Test::Nebulous->setup;
    2427{
    2528    my $neb = Nebulous::Client->new(
     
    7881}
    7982
    80 # force flag
    81 Test::Nebulous->setup;
    82 
     83# test passing in undefined force flag
     84Test::Nebulous->setup;
    8385{
    8486    my $neb = Nebulous::Client->new(
     
    9092}
    9193
    92 Test::Nebulous->setup;
    93 
     94# test passing in force flag = 1
     95Test::Nebulous->setup;
    9496{
    9597    my $neb = Nebulous::Client->new(
     
    101103}
    102104
     105# test passing in force flag = 0
     106Test::Nebulous->setup;
     107{
     108    my $neb = Nebulous::Client->new(
     109        proxy => "http://$hostport/nebulous",
     110    );
     111    $neb->create( "foo" );
     112
     113    is( $neb->delete("foo", 0), 1, "force flag false" );
     114}
     115
     116# test passing in force flag = 0 where disk file is removed
     117Test::Nebulous->setup;
     118eval {
     119    my $neb = Nebulous::Client->new(
     120        proxy => "http://$hostport/nebulous",
     121    );
     122    $neb->create( "foo" );
     123    my $locations = $neb->find_instances( "foo" );
     124    my $diskfile = _get_file_path(@$locations[0]);
     125    unlink $diskfile;
     126    $neb->delete("foo", 0);
     127};
     128like( $@, qr/can't unlink file/, "no force flag, cannot delete inconsistent file" );
     129
     130# test passing in force flag = 1 where disk file is removed
     131Test::Nebulous->setup;
     132{
     133    my $neb = Nebulous::Client->new(
     134        proxy => "http://$hostport/nebulous",
     135    );
     136    $neb->create( "foo" );
     137    my $locations = $neb->find_instances( "foo" );
     138    my $diskfile = _get_file_path(@$locations[0]);
     139    unlink $diskfile;
     140    is( $neb->delete("foo", 1), 1, "force flag true deletes file" );
     141}
     142
     143# test passing in undef force flag where disk file is removed
     144Test::Nebulous->setup;
     145eval {
     146    my $neb = Nebulous::Client->new(
     147        proxy => "http://$hostport/nebulous",
     148    );
     149    $neb->create( "foo" );
     150    my $locations = $neb->find_instances( "foo" );
     151    my $diskfile = _get_file_path(@$locations[0]);
     152    unlink $diskfile;
     153    $neb->delete("foo", undef);
     154};
     155like( $@, qr/can't unlink file/, "no force flag, cannot delete inconsistent file" );
     156
     157# test passing in undefined force flag where disk file is removed
     158Test::Nebulous->setup;
     159eval {
     160    my $neb = Nebulous::Client->new(
     161        proxy => "http://$hostport/nebulous",
     162    );
     163    $neb->create( "foo" );
     164    my $locations = $neb->find_instances( "foo" );
     165    my $diskfile = _get_file_path(@$locations[0]);
     166    unlink $diskfile;
     167    $neb->delete("foo");
     168};
     169like( $@, qr/can't unlink file/, "no force flag, cannot delete inconsistent file" );
     170
    103171Test::Nebulous->setup;
    104172
     
    109177    $neb->delete();
    110178};
    111 like( $@, qr/1 - 2 were expected/, "no params" );
     179like( $@, qr/1 - 3 were expected/, "no params" );
    112180
    113181Test::Nebulous->setup;
     
    127195        proxy => "http://$hostport/nebulous",
    128196    );
    129     $neb->delete( "foo", 0, 2 );
    130 };
    131 like( $@, qr/1 - 2 were expected/, "too many params" );
     197    $neb->delete( "foo", 0, 1, 2 );
     198};
     199like( $@, qr/1 - 3 were expected/, "too many params" );
    132200
    133201Test::Nebulous->cleanup;
Note: See TracChangeset for help on using the changeset viewer.