--[[----------------------------------------------------------------------------

PixelProviderFileCachePurgeWorkerTest.lua

--------------------------------------------------------------------------------

ADOBE CONFIDENTIAL
------------------
Copyright 2015 Adobe Systems Incorporated
All Rights Reserved.

NOTICE: All information contained herein is, and remains the property of
Adobe Systems Incorporated and its suppliers, if any. The intellectual and
technical concepts contained herein are proprietary to Adobe Systems
Incorporated and its suppliers and are protected by all applicable
intellectual property laws, including trade secret and copyright laws.
Dissemination of this information or reproduction of this material is
strictly forbidden unless prior written permission is obtained from
Adobe Systems Incorporated.

----------------------------------------------------------------------------]]--

	-- WF.core.utils
local KSIdGenerator = require 'KSIdGenerator'
local WFCrypto = require 'WFCrypto'
local WFFileUtils = require 'WFFileUtils'
local WFFunctionUtils = require 'WFFunctionUtils'
local KSPathUtils = require 'KSPathUtils'

	-- WF.core.self_test
local WFRxTestCase = require 'WFRxTestCase'
local WFCatMockCatalog = require 'WFCatMockCatalog'

	-- WF.oz_client.managed_catalog.pixel_provider
local PixelProviderFileCachePurgeWorker = 
		require 'PixelProviderFileCachePurgeWorker'
local WFCatPixelPathGenerator = require 'WFCatPixelPathGenerator'
local NmbLocalRenditionDigest = require 'NmbLocalRenditionDigest'

--------------------------------------------------------------------------------

local function makeDocValue( assetId, localId, xmpCameraRaw, userOrientation )

	return {
		_id = assetId,
		newRevId  = KSIdGenerator.uuidInLowercaseHex(),
		_localId = localId,
		type = "asset",
		subtype = "image",
		develop = {
			croppedHeight = 100,
			croppedWidth = 100,
			xmpCameraRaw = xmpCameraRaw,
			userOrientation = userOrientation,
		}
	}

end

--------------------------------------------------------------------------------

local function addRecordToDocStore( rxTest, catalog, assetId, localId, 
									xmpCameraRaw, userOrientation )

	local docValue = makeDocValue( assetId, localId, xmpCameraRaw,
									userOrientation )

	rxTest:expectSingleValue(

		catalog:docStore():bulkSetDocValue( { docValue } ),

		':ignore:' )

	-- Extract the rev Id from the doc store. It's used
	-- when computering the NmbLocalRenditionDigest
	
	rxTest:expectSingleValue(
		catalog:docStore():docValue( docValue._id )
			:pluck( '_revId' )
			:map( function( revId )
				docValue._revId = revId
				return revId
			end ),
		':ignore:' )
		
	return NmbLocalRenditionDigest.maybeComputeFromDocValue( docValue )

end

--------------------------------------------------------------------------------

local function addPath( paths, longSide, basePath, assetId, digest )

	paths[ #paths + 1 ] = WFCatPixelPathGenerator.pathForPreviewDigestAndLongEdge( 
 								basePath, assetId, digest, longSide )

	paths[ #paths + 1 ] = WFCatPixelPathGenerator.pathForPreviewDigestAndLongEdgeJpg( 
 								basePath, assetId, digest, longSide )

	return paths

end

--------------------------------------------------------------------------------

local function makePathsForLongSides( paths, digest, longSides, basePath, assetId )

	return WFFunctionUtils.reduce(
			paths,
				addPath,
					longSides, basePath, assetId, digest )

end

--------------------------------------------------------------------------------

local function makePathsForDigestsLongSides( basePath, assetId, digests, longSides )

	return WFFunctionUtils.reduce(
			{},
				makePathsForLongSides,
					digests, longSides, basePath, assetId )

end

--------------------------------------------------------------------------------

local function makeDummyDataFile( path )

	assert( not WFFileUtils.exists( path ), 
			string.format( "%s exists, refusing to add dummy data to it.", path ) )

	local fh = assert( io.open( path, "w" ), 
						string.format( "Couldn't open %s in order to add fake data", path ) )

	fh:write( "wut" )

	fh:close()

	return path

end

--------------------------------------------------------------------------------

local function addDummyDataFilesForDigestsLongSides( basePath, assetId, digests, longSides )

	local paths = makePathsForDigestsLongSides( basePath, assetId, digests,
													longSides )

	WFFunctionUtils.map( makeDummyDataFile, paths )

	return paths
end

--------------------------------------------------------------------------------

local function checkExists( path, rxTest, expected, desc )

	rxTest:logf( "%s: %s", desc, path )

	rxTest:expectEqual( not not WFFileUtils.exists( path ), expected )

end

--------------------------------------------------------------------------------

local function lastNComponents( path, n )

	local partToStrip = path

	for _ = 1, n do

		partToStrip = KSPathUtils.parent( partToStrip )

	end

	local lastNWithSep = string.sub( path, #partToStrip + 1, #path )

	return string.sub( lastNWithSep, 2, #lastNWithSep )

end

--------------------------------------------------------------------------------

local function makeSuccessfulDeleteTuple( path )

	return { true, lastNComponents( path, 3 ) }

end

--------------------------------------------------------------------------------

local function replacePathWithLastThreeComponents( deleteTuple )

	return { deleteTuple[ 1 ], lastNComponents( deleteTuple[ 2 ], 3 ), 
				unpack( deleteTuple, 3 ) }

end

--------------------------------------------------------------------------------

local function normalizeDeleteResults( deleteTuples )

	return WFFunctionUtils.map( replacePathWithLastThreeComponents,
									deleteTuples )

end

--------------------------------------------------------------------------------

local function rotateHex( h )

	assert( ( h >= '0' and h <= '9' ) or 
				( h >= 'a' and h <= 'f' ) )

	if h == '9' then

		return 'a'

	end

	if h == 'f' then

		return '0'

	end

	return string.char( string.byte( h ) + 1 )

end

--------------------------------------------------------------------------------

local function rotateUUIDCharN( uuid, n )

	local prefix = n > 1 and string.sub( uuid, 1, n - 1 ) or ""

	local rotatedHex = rotateHex( string.sub( uuid, n, n ) )

	local suffix = n < #uuid and string.sub( uuid, n + 1, #uuid ) or ""

	return prefix .. rotatedHex .. suffix


end

--------------------------------------------------------------------------------

local function randomDigest()

	return ( WFCrypto.MD5.digest( KSIdGenerator.uuidInLowercaseHex() ) )

end

--------------------------------------------------------------------------------

local function orderDeleteResults( rslt1, rslt2 )

	if type( rslt1 ) ~= type( rslt2 ) then

		return type( rslt1 ) < type( rslt2 ) 

	end

	if type( rslt1 ) ~= "table" then

		return tostring( rslt1 ) < tostring( rslt2 )

	end

	local exists1, fname1 = unpack( rslt1 )

	local exists2, fname2 = unpack( rslt2 )

	if exists1 ~= exists2 then

		return not not exists1

	end

	return tostring( fname1 ) < tostring( fname2 )

end

--------------------------------------------------------------------------------

local function sortDeleteResults( rslts )

	if type( rslts ) ~= "table" then

		return rslts

	end

	table.sort( rslts, orderDeleteResults )

	return rslts

end

--------------------------------------------------------------------------------

local function localAssetId( i )

	return i

end

--------------------------------------------------------------------------------

local function appendT( ... )

	local appendedT = {}

	local ts = {}

	for i = 1, select( '#', ... ) do

		ts[ i ] = select( i, ... )

		assert( type( ts[ i ] ) == "table",
					string.format( "arg %s is not a table!", i ) )

	end

	local j = 0

	for _, t in ipairs( ts ) do

		for _, v in ipairs( t ) do
		
			j = j + 1

			appendedT[ j ] = v

		end

	end

	return appendedT

end

--------------------------------------------------------------------------------

local function accumulateFlattedPurgeResults( 
				pixelProviderFileCachePurgeWorker )

	local result = { value = {} }

	local purgeResultsSubscription =
				pixelProviderFileCachePurgeWorker
					:purgeResultsStream()
					:map( normalizeDeleteResults )
					:subscribe(
						function( currPurgeResults )

							result.value =
								sortDeleteResults( 
									appendT( result.value, currPurgeResults ) )

						end )

	return purgeResultsSubscription, result

end

--------------------------------------------------------------------------------

local function rxTestDeleteAssetId( rxTest )

	rxTest:setTimeLimit( 60 )

	local wfCatalog = WFCatMockCatalog.createFakeWFCatalog( rxTest )
	
	local basePath = wfCatalog:fileSpec():pixelsPath()

	local assetId1 = KSIdGenerator.uuidInLowercaseHex()

	local xmpCameraRaw = "FakeyVonMcFaker"
	
	local userOrientation = 1

	addRecordToDocStore( rxTest, wfCatalog, assetId1, localAssetId( 1 ), 
									xmpCameraRaw, userOrientation )

	-- choose assetId2 so that it's in the same folder as assetId1
	local assetId2 = rotateUUIDCharN( assetId1, #assetId1 )

	addRecordToDocStore( rxTest, wfCatalog, assetId2, localAssetId( 2 ), 
									xmpCameraRaw, userOrientation )

	-- choose assetId3 so that it's in a different folder as assetId1
	local assetId3 = rotateUUIDCharN( assetId2, 1 )

	addRecordToDocStore( rxTest, wfCatalog, assetId3, localAssetId( 3 ), 
									xmpCameraRaw, userOrientation )

	local digests = { randomDigest(), randomDigest(), randomDigest(),
						randomDigest() }

	local longSides = { 2, 640, 2 ^16 - 2, "full" }

	-- make multiple preview files for assetId1
	local assetId1Files = 
			addDummyDataFilesForDigestsLongSides( basePath, assetId1, digests,
													longSides )

	-- make a non-rendition path in the same folder
	local wutFilePath = makeDummyDataFile( 
							KSPathUtils.child( KSPathUtils.parent( assetId1Files[ 1 ] ),
											"wut.jpg" ) )

	-- make multiple preview files for assetId2
	local assetId2Files = 
			addDummyDataFilesForDigestsLongSides( basePath, assetId2, digests,
													longSides )

	WFFunctionUtils.map( checkExists,
							assetId1Files, rxTest, true, "assetId1 files exist at start" )

	WFFunctionUtils.map( checkExists,
							assetId2Files, rxTest, true, "assetId2 files exist at start" )

	WFFunctionUtils.map( checkExists,
							{ wutFilePath }, rxTest, true, "wutFilePath exist at start" )

	local pixelProviderFileCachePurgeWorker = 
			PixelProviderFileCachePurgeWorker( wfCatalog )

	local scanWatcher = 
			rxTest:observe( 
				pixelProviderFileCachePurgeWorker
					:deletedStatusStream() )

	local purgeResultsSubscription, actualPurgeResultsContainer =
			accumulateFlattedPurgeResults( 
				pixelProviderFileCachePurgeWorker )

	rxTest:log( "delete an assetId that ain't there" )

	wfCatalog:docStore():deleteDoc( assetId3 )

	scanWatcher:expectDataWithinTime( 1, assetId3 )

	purgeResultsSubscription:dispose()

	rxTest:expectEqual( actualPurgeResultsContainer.value, {} )

	WFFunctionUtils.map( checkExists,
							assetId1Files, rxTest, true, "assetId1 files exist after deleting nonesuch assetId" )

	WFFunctionUtils.map( checkExists,
							assetId2Files, rxTest, true, "assetId2 files exist after deleting nonesuch assetId" )

	WFFunctionUtils.map( checkExists,
							{ wutFilePath }, rxTest, true, "wutFilePath exist after deleting nonesuch assetId" )

	rxTest:log( "delete assetId1" )

	purgeResultsSubscription, actualPurgeResultsContainer =
			accumulateFlattedPurgeResults( 
				pixelProviderFileCachePurgeWorker )

	local expectedSuccessfulDeletes = 
			sortDeleteResults( 
				WFFunctionUtils.map ( makeSuccessfulDeleteTuple, 
										assetId1Files ) )

	wfCatalog:docStore():deleteDoc( assetId1 )

	scanWatcher:expectDataWithinTime( 1, assetId1 )

	purgeResultsSubscription:dispose()

	rxTest:expectEqual( actualPurgeResultsContainer.value, expectedSuccessfulDeletes )

	WFFunctionUtils.map( checkExists,
							assetId1Files, rxTest, false, "assetId1 files gone" )

	WFFunctionUtils.map( checkExists,
							assetId2Files, rxTest, true, "assetId2 files exist after assetId1 delete" )

	WFFunctionUtils.map( checkExists,
							{ wutFilePath }, rxTest, true, "wutFilePath exist after assetId1 delete" )

	rxTest:log( "delete assetId2" )

	purgeResultsSubscription, actualPurgeResultsContainer =
			accumulateFlattedPurgeResults( 
				pixelProviderFileCachePurgeWorker )

	expectedSuccessfulDeletes = 
			sortDeleteResults( 
				WFFunctionUtils.map ( makeSuccessfulDeleteTuple, 
										assetId2Files ) )

	wfCatalog:docStore():deleteDoc( assetId2 )

	scanWatcher:expectDataWithinTime( 1, assetId2 )

	purgeResultsSubscription:dispose()

	rxTest:expectEqual( actualPurgeResultsContainer.value, expectedSuccessfulDeletes )

	WFFunctionUtils.map( checkExists,
							assetId2Files, rxTest, false, "assetId2 files gone" )

	WFFunctionUtils.map( checkExists,
							{ wutFilePath }, rxTest, true, "wutFilePath exist after assetId2 delete" )
	
	rxTest:finally( 
		function()

			WFFileUtils.delete( wutFilePath )
			pixelProviderFileCachePurgeWorker:close()
			
		end )
	
end

--------------------------------------------------------------------------------

local function rxTestBulkDeleteAssetId( rxTest )

	rxTest:setTimeLimit( 60 )

	local wfCatalog = WFCatMockCatalog.createFakeWFCatalog( rxTest )
	
	local basePath = wfCatalog:fileSpec():pixelsPath()

	local assetId1 = KSIdGenerator.uuidInLowercaseHex()

	local xmpCameraRaw = "FakeyVonMcFaker"
	
	local userOrientation = 1

	addRecordToDocStore( rxTest, wfCatalog, assetId1, localAssetId( 1 ), 
									xmpCameraRaw, userOrientation )

	-- choose assetId2 so that it's in different folder as assetId1
	local assetId2 = rotateUUIDCharN( assetId1, 1 )

	addRecordToDocStore( rxTest, wfCatalog, assetId2, localAssetId( 2 ), 
									xmpCameraRaw, userOrientation )

	-- choose assetId3 so that it's in a same folder as assetId2
	local assetId3 = rotateUUIDCharN( assetId2, #assetId2 )

	addRecordToDocStore( rxTest, wfCatalog, assetId3, localAssetId( 3 ), 
									xmpCameraRaw, userOrientation )

	-- choose assetId4 so that it's in a different folder as assetId3
	local assetId4 = rotateUUIDCharN( assetId3, 1 )

	addRecordToDocStore( rxTest, wfCatalog, assetId4, localAssetId( 4 ), 
									xmpCameraRaw, userOrientation )

	local digests = { randomDigest(), randomDigest(), randomDigest(),
						randomDigest() }

	local longSides = { 2, 640, 2 ^16 - 2, "full" }

	-- make multiple preview files for assetId1
	local assetId1Files = 
			addDummyDataFilesForDigestsLongSides( basePath, assetId1, digests,
													longSides )

	-- make a non-rendition path in the same folder
	local wutFilePath = makeDummyDataFile( 
							KSPathUtils.child( KSPathUtils.parent( assetId1Files[ 1 ] ),
											"wut.jpg" ) )

	-- make multiple preview files for assetId2
	local assetId2Files = 
			addDummyDataFilesForDigestsLongSides( basePath, assetId2, digests,
													longSides )

	WFFunctionUtils.map( checkExists,
							assetId1Files, rxTest, true, "assetId1 files exist at start" )

	WFFunctionUtils.map( checkExists,
							assetId2Files, rxTest, true, "assetId2 files exist at start" )

	WFFunctionUtils.map( checkExists,
							{ wutFilePath }, rxTest, true, "wutFilePath exist at start" )

	local pixelProviderFileCachePurgeWorker = 
			PixelProviderFileCachePurgeWorker( wfCatalog )

	local scanWatcher = 
			rxTest:observe( 
				pixelProviderFileCachePurgeWorker
					:deletedStatusStream() )

	local purgeResultsSubscription, actualPurgeResultsContainer =
			accumulateFlattedPurgeResults( 
				pixelProviderFileCachePurgeWorker )

	wfCatalog:docStore():deleteDoc( assetId3 )

	scanWatcher:expectDataWithinTime( 1, assetId3 )

	purgeResultsSubscription:dispose()

	rxTest:expectEqual( actualPurgeResultsContainer.value, {} )

	purgeResultsSubscription, actualPurgeResultsContainer =
			accumulateFlattedPurgeResults( 
				pixelProviderFileCachePurgeWorker )

	wfCatalog:docStore():deleteDoc( assetId1 )

	wfCatalog:docStore():deleteDoc( assetId2 )

	wfCatalog:docStore():deleteDoc( assetId4 )

	local expectedSuccessfulDeletes = 
			sortDeleteResults( 
				appendT(
					WFFunctionUtils.map ( makeSuccessfulDeleteTuple, 
											assetId1Files ),
					WFFunctionUtils.map ( makeSuccessfulDeleteTuple, 
											assetId2Files ) )
				)

	scanWatcher:expectDataWithinTime( 1, assetId1 )
	scanWatcher:expectDataWithinTime( 1, assetId2 )
	scanWatcher:expectDataWithinTime( 1, assetId4 )

	purgeResultsSubscription:dispose()

	rxTest:expectEqual( actualPurgeResultsContainer.value, expectedSuccessfulDeletes )

	WFFunctionUtils.map( checkExists,
							assetId1Files, rxTest, false, "assetId1 files gone" )

	WFFunctionUtils.map( checkExists,
							assetId2Files, rxTest, false, "assetId2 files gone" )

	WFFunctionUtils.map( checkExists,
							{ wutFilePath }, rxTest, true, "wutFilePath exist after assetId2 delete" )
	
	rxTest:finally( 
		function()

			WFFileUtils.delete( wutFilePath  )
			pixelProviderFileCachePurgeWorker:close()
			
		end )
	
end

--------------------------------------------------------------------------------

local function xmpCameraRaw( i )

	return string.format( "FakeyVonMcFaker%d", i )

end

--------------------------------------------------------------------------------

local function userOrientation( i )

	return i % 4

end

--------------------------------------------------------------------------------

local function doesNotMatch( targetVal )

	return function( val )

		return val ~= targetVal and val or nil

	end

end

--------------------------------------------------------------------------------

local function rxTestScan( rxTest )

	rxTest:setTimeLimit( 60 )
	
	require 'WFConfiguration'.PixelProvider.SettingsCachePurgeOlderThan = 0
	
	local wfCatalog = WFCatMockCatalog.createFakeWFCatalog( rxTest )
	
	local basePath = wfCatalog:fileSpec():pixelsPath()

	local assetId1 = KSIdGenerator.uuidInLowercaseHex()

	local digest1 = addRecordToDocStore( rxTest, wfCatalog, assetId1,
											localAssetId( 1 ), 
											xmpCameraRaw( 1 ), 
											userOrientation( 1 ) )

	-- choose assetId2 so that it's in the same folder as assetId1
	local assetId2 = rotateUUIDCharN( assetId1, #assetId1 )

	local digest2 = addRecordToDocStore( rxTest, wfCatalog, assetId2,
											localAssetId( 2 ), 
											xmpCameraRaw( 2 ), 
											userOrientation( 2 ) )

	-- assetId3 won't have renditions for its current digest
	local assetId3 = rotateUUIDCharN( assetId1, 1 )

	addRecordToDocStore( rxTest, wfCatalog, assetId3,
											localAssetId( 3 ), 
											xmpCameraRaw( 3 ), 
											userOrientation( 3 ) )

	-- assetId4 won't have a docStore record
	local assetId4 = KSIdGenerator.uuidInLowercaseHex()
	
	-- assetId5 will have an external settings xmp
	local assetId5 = KSIdGenerator.uuidInLowercaseHex()
	
	addRecordToDocStore( rxTest, wfCatalog, assetId5,
									localAssetId( 5 ),
									{ 
										sha256 = 'usedFakeSha256',
									},
									userOrientation( 5 ) )
	
	local otherDigest = randomDigest()

	local digests = { digest1, digest2, otherDigest }

	local longSides = { 2, 640, 2 ^16 - 2, "full" }

	-- make multiple preview files for assetId1
	local assetId1Files = 
			addDummyDataFilesForDigestsLongSides( basePath, assetId1, digests,
													longSides )
	
	-- make a non-rendition path in the same folder
	local wutFilePath = makeDummyDataFile( 
							KSPathUtils.child( KSPathUtils.parent( assetId1Files[ 1 ] ),
											"wut.jpg" ) )

	-- make multiple preview files for assetId2
	local assetId2Files = 
			addDummyDataFilesForDigestsLongSides( basePath, assetId2, digests,
													longSides )

	-- make multiple preview files for assetId3
	local assetId3Files = 
			addDummyDataFilesForDigestsLongSides( basePath, assetId3, digests,
													longSides )
	-- make multiple preview files for assetId4
	local assetId4Files = 
			addDummyDataFilesForDigestsLongSides( basePath, assetId4, digests,
													longSides )
	
	local assetId5SettingsXmpFile =
			makeDummyDataFile( KSPathUtils.child( wfCatalog:fileSpec():folderForSettingsXmp(), 'usedFakeSha256' ) )
			
	local unusedSettingsXmpFile = 
			makeDummyDataFile( KSPathUtils.child( wfCatalog:fileSpec():folderForSettingsXmp(), 'unusedFakeSha256' ) )
			
	WFFunctionUtils.map( checkExists,
							assetId1Files, rxTest, true, "assetId1 rendition files exist at start" )

	WFFunctionUtils.map( checkExists,
							assetId2Files, rxTest, true, "assetId2 rendition files exist at start" )

	WFFunctionUtils.map( checkExists,
							{ wutFilePath }, rxTest, true, "wutFilePath exists at start" )

	WFFunctionUtils.map( checkExists,
							assetId3Files, rxTest, true, "assetId3 rendition files exist at start" )

	WFFunctionUtils.map( checkExists,
							assetId4Files, rxTest, true, "assetId4 rendition files exist at start" )
	
	WFFunctionUtils.map( checkExists,
							{ assetId5SettingsXmpFile }, rxTest, true, "assetId5 settings files exist at start" )
	
	WFFunctionUtils.map( checkExists,
							{ unusedSettingsXmpFile }, rxTest, true, "assetId5 settings files exist at start" )

	local pixelProviderFileCachePurgeWorker = 
			PixelProviderFileCachePurgeWorker( wfCatalog, { minSettingsXmpAgeInSeconds = 0 } )

	local scanWatcher = 
			rxTest:observe( 
				pixelProviderFileCachePurgeWorker
					:scanStatusStream() )

	local purgeResultsSubscription, actualPurgeResultsContainer =
			accumulateFlattedPurgeResults( 
				pixelProviderFileCachePurgeWorker )

	pixelProviderFileCachePurgeWorker:scanAndPurge()

	-- expect to purge all assetId1 files with mismatched digests
	local expectedAssetId1Deletes = 
			makePathsForDigestsLongSides( 
				basePath, assetId1, 
				WFFunctionUtils.filter( doesNotMatch( digest1 ), digests ),
				longSides )

	-- expect to purge all assetId2 files with mismatched digests
	local expectedAssetId2Deletes = 
			makePathsForDigestsLongSides( 
				basePath, assetId2, 
				WFFunctionUtils.filter( doesNotMatch( digest2 ), digests ),
				longSides )

	-- expect to purge all assetId4 files because it's not in docstore
	local expectedAssetId4Deletes = 
			makePathsForDigestsLongSides( basePath, assetId4, digests,
											longSides )
	
	-- expect to purge the unused settings xmp file
	local expectedSettingsXmpDeletes = { unusedSettingsXmpFile }
	
	local expectedDeletePaths = appendT( expectedAssetId1Deletes,
											expectedAssetId2Deletes,
											expectedAssetId4Deletes,
											expectedSettingsXmpDeletes )
											
	local expectedSuccessfulDeletes = 
			sortDeleteResults( 
				WFFunctionUtils.map ( 
					makeSuccessfulDeleteTuple, 
						expectedDeletePaths ) )

	scanWatcher:expectData( "done" )

	purgeResultsSubscription:dispose()

	rxTest:expectEqual( expectedSuccessfulDeletes, actualPurgeResultsContainer.value )

	rxTest:finally( 
		function()

			pixelProviderFileCachePurgeWorker:close()

			WFFunctionUtils.map( WFFileUtils.delete, assetId1Files )

			WFFunctionUtils.map( WFFileUtils.delete, assetId2Files )

			WFFunctionUtils.map( WFFileUtils.delete, assetId3Files )

			WFFunctionUtils.map( WFFileUtils.delete, assetId4Files )
			
			WFFileUtils.delete( assetId5SettingsXmpFile )
			
			WFFileUtils.delete( unusedSettingsXmpFile )

			WFFileUtils.delete( wutFilePath  )
			

		end )
	
end

--==============================================================================

-- FIXME [jandrew 2016-10-04]: These tests fail on android.
-- FIXME [ashj 2019-02-08]: WFFolderWalkerImp is not implemented on Android

local WFPlatformInfo = require 'WFPlatformInfo'

if WFPlatformInfo.isAndroid then
	return {}
else
	return WFRxTestCase.wrapSuite( 'PixelProviderFileCachePurgeWorkerTest', {

		rxTestDeleteAssetId = rxTestDeleteAssetId,

		rxTestBulkDeleteAssetId = rxTestBulkDeleteAssetId,

		rxTestScan = rxTestScan,

	} )
end
