IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 28, 2019, 4:26:42 PM (7 years ago)
Author:
eugene
Message:

find_instances has some inconsistencies : meaning of hard_volume, use of find_invalid

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20191011/Nebulous/t/59_client_delete.t

    r24440 r40998  
    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
     26# test of the eval thing;
     27## Test::Nebulous->setup;
     28## eval {
     29##     my $neb = Nebulous::Client->new(
     30##         proxy => "http://$hostport/nebulous",
     31##     );
     32##     print "1\n";
     33##     $neb->delete( "foo", 0, 1, 2 );
     34##     print "2\n";
     35## };
     36## like( $@, qr/1 - 3 were expected/, "too many params" );
     37## die "ex";
     38
     39Test::Nebulous->setup;
    2440{
    2541    my $neb = Nebulous::Client->new(
     
    7894}
    7995
    80 # force flag
    81 Test::Nebulous->setup;
    82 
     96# test passing in undefined force flag
     97Test::Nebulous->setup;
    8398{
    8499    my $neb = Nebulous::Client->new(
     
    90105}
    91106
    92 Test::Nebulous->setup;
    93 
     107# test passing in force flag = 1
     108Test::Nebulous->setup;
    94109{
    95110    my $neb = Nebulous::Client->new(
     
    101116}
    102117
     118# test passing in force flag = 0
     119Test::Nebulous->setup;
     120{
     121    my $neb = Nebulous::Client->new(
     122        proxy => "http://$hostport/nebulous",
     123    );
     124    $neb->create( "foo" );
     125
     126    is( $neb->delete("foo", 0), 1, "force flag false" );
     127}
     128
     129# test passing in force flag = 0 where disk file is removed
     130Test::Nebulous->setup;
     131eval {
     132    my $neb = Nebulous::Client->new(
     133        proxy => "http://$hostport/nebulous",
     134    );
     135    $neb->create( "foo" );
     136    my $locations = $neb->find_instances( "foo" );
     137    my $diskfile = _get_file_path(@$locations[0]);
     138    unlink $diskfile;
     139    $neb->delete("foo", 0);
     140};
     141like( $@, qr/can't unlink file/, "no force flag, cannot delete inconsistent file" );
     142
     143# test passing in force flag = 1 where disk file is removed
     144Test::Nebulous->setup;
     145{
     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    is( $neb->delete("foo", 1), 1, "force flag true deletes file" );
     154}
     155
     156# test passing in undef force flag where disk file is removed
     157Test::Nebulous->setup;
     158eval {
     159    my $neb = Nebulous::Client->new(
     160        proxy => "http://$hostport/nebulous",
     161    );
     162    $neb->create( "foo" );
     163    my $locations = $neb->find_instances( "foo" );
     164    my $diskfile = _get_file_path(@$locations[0]);
     165    unlink $diskfile;
     166    $neb->delete("foo", undef);
     167};
     168like( $@, qr/can't unlink file/, "no force flag, cannot delete inconsistent file" );
     169
     170# test passing in undefined force flag where disk file is removed
     171Test::Nebulous->setup;
     172eval {
     173    my $neb = Nebulous::Client->new(
     174        proxy => "http://$hostport/nebulous",
     175    );
     176    $neb->create( "foo" );
     177    my $locations = $neb->find_instances( "foo" );
     178    my $diskfile = _get_file_path(@$locations[0]);
     179    unlink $diskfile;
     180    $neb->delete("foo");
     181};
     182like( $@, qr/can't unlink file/, "no force flag, cannot delete inconsistent file" );
     183
    103184Test::Nebulous->setup;
    104185
     
    109190    $neb->delete();
    110191};
    111 like( $@, qr/1 - 2 were expected/, "no params" );
     192like( $@, qr/1 - 3 were expected/, "no params" );
    112193
    113194Test::Nebulous->setup;
     
    127208        proxy => "http://$hostport/nebulous",
    128209    );
    129     $neb->delete( "foo", 0, 2 );
    130 };
    131 like( $@, qr/1 - 2 were expected/, "too many params" );
     210    $neb->delete( "foo", 0, 1, 2 );
     211};
     212like( $@, qr/1 - 3 were expected/, "too many params" );
    132213
    133214Test::Nebulous->cleanup;
Note: See TracChangeset for help on using the changeset viewer.