Changeset 41172 for trunk/Nebulous/t/59_client_delete.t
- Timestamp:
- Nov 27, 2019, 12:04:14 PM (7 years ago)
- File:
-
- 1 edited
-
trunk/Nebulous/t/59_client_delete.t (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous/t/59_client_delete.t
r24440 r41172 10 10 use Apache::Test qw( -withtestmore ); 11 11 12 plan tests => 1 3;12 plan tests => 18; 13 13 14 14 use lib qw( ./t ./lib ); … … 20 20 my $hostport = Apache::Test->config->{ 'hostport' }; 21 21 22 Test::Nebulous->setup; 23 22 # ensure fresh start: 23 Test::Nebulous->setup; 24 Test::Nebulous->cleanup; 25 26 Test::Nebulous->setup; 24 27 { 25 28 my $neb = Nebulous::Client->new( … … 78 81 } 79 82 80 # force flag 81 Test::Nebulous->setup; 82 83 # test passing in undefined force flag 84 Test::Nebulous->setup; 83 85 { 84 86 my $neb = Nebulous::Client->new( … … 90 92 } 91 93 92 Test::Nebulous->setup; 93 94 # test passing in force flag = 1 95 Test::Nebulous->setup; 94 96 { 95 97 my $neb = Nebulous::Client->new( … … 101 103 } 102 104 105 # test passing in force flag = 0 106 Test::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 117 Test::Nebulous->setup; 118 eval { 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 }; 128 like( $@, 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 131 Test::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 144 Test::Nebulous->setup; 145 eval { 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 }; 155 like( $@, 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 158 Test::Nebulous->setup; 159 eval { 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 }; 169 like( $@, qr/can't unlink file/, "no force flag, cannot delete inconsistent file" ); 170 103 171 Test::Nebulous->setup; 104 172 … … 109 177 $neb->delete(); 110 178 }; 111 like( $@, qr/1 - 2were expected/, "no params" );179 like( $@, qr/1 - 3 were expected/, "no params" ); 112 180 113 181 Test::Nebulous->setup; … … 127 195 proxy => "http://$hostport/nebulous", 128 196 ); 129 $neb->delete( "foo", 0, 2 );130 }; 131 like( $@, qr/1 - 2were expected/, "too many params" );197 $neb->delete( "foo", 0, 1, 2 ); 198 }; 199 like( $@, qr/1 - 3 were expected/, "too many params" ); 132 200 133 201 Test::Nebulous->cleanup;
Note:
See TracChangeset
for help on using the changeset viewer.
