tests/SecureDelete.Tests.ps1

$moduleRoot = Split-Path -Parent $PSScriptRoot
Import-Module (Join-Path $moduleRoot 'Octa.psd1') -Force
# Clear-OctaFileSecurely is an internal helper (not in FunctionsToExport) - dot-source directly.
. (Join-Path $moduleRoot 'public\Invoke-OctaDiskCleanup.ps1')

Describe 'Clear-OctaFileSecurely (007 US3)' {
    It 'overwrites a file''s on-disk bytes before it would be deleted' {
        $testFile = Join-Path $env:TEMP ('octa-secure-delete-test-{0}.bin' -f [guid]::NewGuid())
        $originalBytes = [byte[]](1..64)
        [System.IO.File]::WriteAllBytes($testFile, $originalBytes)

        try {
            Clear-OctaFileSecurely -Path $testFile
            $overwrittenBytes = [System.IO.File]::ReadAllBytes($testFile)
            $overwrittenBytes.Length | Should Be $originalBytes.Length
            (Compare-Object $originalBytes $overwrittenBytes) | Should Not Be $null
        }
        finally {
            Remove-Item -Path $testFile -Force -ErrorAction SilentlyContinue
        }
    }
}