|
| 1 | +Set-StrictMode -Version Latest |
| 2 | + |
| 3 | +BeforeAll { |
| 4 | + $script:RepoRoot = Join-Path $PSScriptRoot '..' |
| 5 | + $env:PWSH_TEST_SKIP_POSTGRES_TOOLKIT_MAIN = '1' |
| 6 | + |
| 7 | + foreach ($relativePath in @( |
| 8 | + 'scripts/pwsh/devops/postgresql/core/logging.ps1' |
| 9 | + 'scripts/pwsh/devops/postgresql/core/process.ps1' |
| 10 | + 'scripts/pwsh/devops/postgresql/core/arguments.ps1' |
| 11 | + 'scripts/pwsh/devops/postgresql/core/connection.ps1' |
| 12 | + 'scripts/pwsh/devops/postgresql/core/context.ps1' |
| 13 | + 'scripts/pwsh/devops/postgresql/core/formats.ps1' |
| 14 | + 'scripts/pwsh/devops/postgresql/core/validation.ps1' |
| 15 | + 'scripts/pwsh/devops/postgresql/commands/help.ps1' |
| 16 | + 'scripts/pwsh/devops/postgresql/main.ps1' |
| 17 | + )) { |
| 18 | + . (Join-Path $script:RepoRoot $relativePath) |
| 19 | + } |
| 20 | +} |
| 21 | + |
| 22 | +Describe 'Get-PostgresToolkitHelpText' { |
| 23 | + It '输出四个核心命令和示例' { |
| 24 | + $helpText = Get-PostgresToolkitHelpText |
| 25 | + |
| 26 | + $helpText | Should -Match 'backup' |
| 27 | + $helpText | Should -Match 'restore' |
| 28 | + $helpText | Should -Match 'import-csv' |
| 29 | + $helpText | Should -Match 'install-tools' |
| 30 | + $helpText | Should -Match 'Postgres-Toolkit.ps1 backup' |
| 31 | + } |
| 32 | +} |
| 33 | + |
| 34 | +Describe 'Invoke-PostgresToolkitCommand' { |
| 35 | + It '未传命令时返回帮助文本而不是抛错' { |
| 36 | + $result = Invoke-PostgresToolkitCommand -CommandName '' -RawArguments @() |
| 37 | + |
| 38 | + $result.ExitCode | Should -Be 0 |
| 39 | + $result.Output | Should -Match 'Usage' |
| 40 | + } |
| 41 | +} |
0 commit comments