@@ -240,20 +240,16 @@ pub async fn run_gc(store: Store, config: GcConfig) {
240240
241241#[ cfg( test) ]
242242mod tests {
243- use std:: {
244- io:: { self } ,
245- path:: Path ,
246- } ;
243+ use std:: io:: { self } ;
247244
248- use bao_tree:: { io:: EncodeError , ChunkNum } ;
245+ use bao_tree:: io:: EncodeError ;
249246 use range_collections:: RangeSet2 ;
250247 use testresult:: TestResult ;
251248
252249 use super :: * ;
253250 use crate :: {
254251 api:: { blobs:: AddBytesOptions , ExportBaoError , RequestError , Store } ,
255252 hashseq:: HashSeq ,
256- store:: fs:: { options:: PathOptions , tests:: create_n0_bao} ,
257253 BlobFormat ,
258254 } ;
259255
@@ -266,13 +262,15 @@ mod tests {
266262 let et = blobs. add_slice ( "e" ) . temp_tag ( ) . await ?;
267263 let ft = blobs. add_slice ( "f" ) . temp_tag ( ) . await ?;
268264 let gt = blobs. add_slice ( "g" ) . temp_tag ( ) . await ?;
265+ let ht = blobs. add_slice ( "h" ) . with_named_tag ( "h" ) . await ?;
269266 let a = * at. hash ( ) ;
270267 let b = * bt. hash ( ) ;
271268 let c = * ct. hash ( ) ;
272269 let d = * dt. hash ( ) ;
273270 let e = * et. hash ( ) ;
274271 let f = * ft. hash ( ) ;
275272 let g = * gt. hash ( ) ;
273+ let h = ht. hash ;
276274 store. tags ( ) . set ( "c" , * ct. hash_and_format ( ) ) . await ?;
277275 let dehs = [ d, e] . into_iter ( ) . collect :: < HashSeq > ( ) ;
278276 let hehs = blobs
@@ -292,6 +290,7 @@ mod tests {
292290 store. tags ( ) . set ( "fg" , * fghs. hash_and_format ( ) ) . await ?;
293291 drop ( fghs) ;
294292 drop ( bt) ;
293+ store. tags ( ) . delete ( "h" ) . await ?;
295294 let mut live = HashSet :: new ( ) ;
296295 gc_run_once ( store, & mut live) . await ?;
297296 // a is protected because we keep the temp tag
@@ -313,12 +312,19 @@ mod tests {
313312 assert ! ( store. has( f) . await ?) ;
314313 assert ! ( live. contains( & g) ) ;
315314 assert ! ( store. has( g) . await ?) ;
315+ // h is not protected because we deleted the tag before gc ran
316+ assert ! ( !live. contains( & h) ) ;
317+ assert ! ( !store. has( h) . await ?) ;
316318 drop ( at) ;
317319 drop ( hehs) ;
318320 Ok ( ( ) )
319321 }
320322
321- async fn gc_file_delete ( path : & Path , store : & Store ) -> TestResult < ( ) > {
323+ #[ cfg( feature = "fs-store" ) ]
324+ async fn gc_file_delete ( path : & std:: path:: Path , store : & Store ) -> TestResult < ( ) > {
325+ use bao_tree:: ChunkNum ;
326+
327+ use crate :: store:: { fs:: options:: PathOptions , util:: tests:: create_n0_bao} ;
322328 let mut live = HashSet :: new ( ) ;
323329 let options = PathOptions :: new ( & path. join ( "db" ) ) ;
324330 // create a large complete file and check that the data and outboard files are deleted by gc
@@ -366,6 +372,7 @@ mod tests {
366372 }
367373
368374 #[ tokio:: test]
375+ #[ cfg( feature = "fs-store" ) ]
369376 async fn gc_smoke_fs ( ) -> TestResult {
370377 tracing_subscriber:: fmt:: try_init ( ) . ok ( ) ;
371378 let testdir = tempfile:: tempdir ( ) ?;
@@ -385,6 +392,7 @@ mod tests {
385392 }
386393
387394 #[ tokio:: test]
395+ #[ cfg( feature = "fs-store" ) ]
388396 async fn gc_check_deletion_fs ( ) -> TestResult {
389397 tracing_subscriber:: fmt:: try_init ( ) . ok ( ) ;
390398 let testdir = tempfile:: tempdir ( ) ?;
0 commit comments