@@ -251,19 +251,22 @@ module Blobstore
251251 end
252252
253253 describe '#delete_all_in_path' do
254- it 'deletes all files in a specific path' do
255- path1 = File . join ( base_path , directory_key , 'path1' , 'file1' )
256- path2 = File . join ( base_path , directory_key , 'path2' , 'file2' )
257-
258- FileUtils . mkdir_p ( File . dirname ( path1 ) )
259- FileUtils . mkdir_p ( File . dirname ( path2 ) )
260- File . write ( path1 , 'content1' )
261- File . write ( path2 , 'content2' )
262-
263- client . delete_all_in_path ( 'path1' )
264-
265- expect ( File . exist? ( path1 ) ) . to be ( false )
266- expect ( File . exist? ( path2 ) ) . to be ( true )
254+ it 'deletes all files in the partitioned directory for the given key' do
255+ key1 = 'abcdef1234'
256+ key2 = 'abcdef5678'
257+ other_key = 'ffff001234'
258+ tmpfile = Tempfile . new . tap { |f | f . write ( 'x' ) && f . flush }
259+
260+ client . cp_to_blobstore ( tmpfile . path , key1 )
261+ client . cp_to_blobstore ( tmpfile . path , key2 )
262+ client . cp_to_blobstore ( tmpfile . path , other_key )
263+
264+ # key1 and key2 share the same partitioned directory (ab/cd/)
265+ client . delete_all_in_path ( key1 )
266+
267+ expect ( client . exists? ( key1 ) ) . to be ( false )
268+ expect ( client . exists? ( key2 ) ) . to be ( false )
269+ expect ( client . exists? ( other_key ) ) . to be ( true )
267270 end
268271 end
269272
0 commit comments