File: test25.ps1

package info (click to toggle)
par2cmdline 1.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,204 kB
  • sloc: cpp: 14,330; sh: 6,457; makefile: 204
file content (43 lines) | stat: -rw-r--r-- 1,096 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env pwsh
# Test 25: par2 with full path

$ErrorActionPreference = "Stop"

# Source common test functions
. (Join-Path $PSScriptRoot "testfuncs.ps1")

$testname = [System.IO.Path]::GetFileNameWithoutExtension($MyInvocation.MyCommand.Name)

try {
    Initialize-Test -TestName $testname

    Write-Banner "par2 with full path"

    Set-Content -Path "some-file" -Value "file contents"
    Copy-Item "some-file" "some-file.orig"

    $fullPath = (Resolve-Path "some-file").Path
    $exitCode = Invoke-Par2 -Arguments @("create", $fullPath)
    if ($exitCode -ne 0) {
        Exit-TestWithError "Failed to create parchive"
    }

    Set-Content -Path "some-file" -Value "corrupted contents"

    $exitCode = Invoke-Par2 -Arguments @("repair", "some-file")
    if ($exitCode -ne 0) {
        Exit-TestWithError "Failed to repair"
    }

    if (-not (Compare-Files "some-file" "some-file.orig")) {
        Exit-TestWithError "Repaired file does not match original"
    }

    Complete-Test
    exit 0
}
catch {
    Write-Host "ERROR: $_" -ForegroundColor Red
    Complete-Test
    exit 1
}