Files
easyai/scripts/Test-RedisPersistence.ps1
T
wangbo 74ada0b0bf
Test deployment public URL (Linux) / test-linux (push) Canceled after 0s
Test start.ps1 (Windows) / test-windows (push) Canceled after 0s
fix(deploy): 加固 Redis 持久化与旧环境启动配置
2026-09-23 16:20:55 +08:00

38 lines
1.2 KiB
PowerShell

$ErrorActionPreference = 'Stop'
. (Join-Path $PSScriptRoot 'Assert-RedisPersistence.ps1')
$projectRoot = Split-Path $PSScriptRoot -Parent
$expected = [System.IO.Path]::GetFullPath((Join-Path $projectRoot 'data/redis'))
$script:state = 'absent'
function docker {
$global:LASTEXITCODE = 0
switch ($args[0]) {
'info' {
if ($script:state -eq 'unavailable') { $global:LASTEXITCODE = 1 }
return
}
'container' {
if ($script:state -eq 'absent') { $global:LASTEXITCODE = 1 }
return
}
'inspect' {
switch ($script:state) {
'mounted' { return "bind|$expected" }
'wrong_mount' { return 'bind|/other/redis' }
default { return '' }
}
}
}
}
Assert-RedisPersistence -ProjectRoot $projectRoot
$script:state = 'mounted'
Assert-RedisPersistence -ProjectRoot $projectRoot
foreach ($unsafe in @('unavailable', 'no_mount', 'wrong_mount')) {
$script:state = $unsafe
$rejected = $false
try { Assert-RedisPersistence -ProjectRoot $projectRoot } catch { $rejected = $true }
if (-not $rejected) { throw "Unsafe Redis state accepted: $unsafe" }
}
Write-Host 'Redis persistence PowerShell tests passed'