From fac796ee431d36169956a3c5e65133a70c43a7c8 Mon Sep 17 00:00:00 2001 From: Clint Branham Date: Fri, 20 Mar 2026 12:22:03 -0500 Subject: [PATCH] test: add network CRUD integration tests - Add bridge create/update/remove/apply test cases - Add interface type filter test - Tests exercise New-PveNetwork, Set-PveNetwork, Remove-PveNetwork, and Invoke-PveNetworkApply against live PVE Co-Authored-By: Claude Opus 4.6 (1M context) --- .../Integration/Integration.Tests.ps1 | 63 ++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/tests/PSProxmoxVE.Tests/Integration/Integration.Tests.ps1 b/tests/PSProxmoxVE.Tests/Integration/Integration.Tests.ps1 index 4e9ccf1..5df6e7f 100644 --- a/tests/PSProxmoxVE.Tests/Integration/Integration.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Integration/Integration.Tests.ps1 @@ -530,13 +530,74 @@ Describe 'Integration Tests' -Tag 'Integration' { } # ----------------------------------------------------------------------- - Context 'Network' { + Context 'Network — Read' { It 'Should list networks' { if (Skip-IfNoTarget) { return } $networks = Get-PveNetwork -Node $script:Node $networks | Should -Not -BeNullOrEmpty } + + It 'Should filter by interface type' { + if (Skip-IfNoTarget) { return } + + # Filter for bridges — every PVE node has at least vmbr0 + $bridges = Get-PveNetwork -Node $script:Node -Type 'bridge' + $bridges | Should -Not -BeNullOrEmpty + $bridges | ForEach-Object { $_.Type | Should -Be 'bridge' } + } + } + + # ----------------------------------------------------------------------- + Context 'Network — CRUD' { + It 'Should create a Linux bridge' { + if (Skip-IfNoTarget) { return } + + { New-PveNetwork ` + -Node $script:Node ` + -Iface 'vmbr99' ` + -Type 'bridge' ` + -Autostart ` + -ErrorAction Stop } | Should -Not -Throw + } + + It 'Should find the new bridge in pending changes' { + if (Skip-IfNoTarget) { return } + + $networks = Get-PveNetwork -Node $script:Node + $networks | Where-Object { $_.Iface -eq 'vmbr99' } | + Should -Not -BeNullOrEmpty + } + + It 'Should update bridge comments' { + if (Skip-IfNoTarget) { return } + + { Set-PveNetwork ` + -Node $script:Node ` + -Iface 'vmbr99' ` + -Comments 'Created by Pester integration test' ` + -ErrorAction Stop } | Should -Not -Throw + } + + It 'Should remove the bridge' { + if (Skip-IfNoTarget) { return } + + { Remove-PveNetwork ` + -Node $script:Node ` + -Iface 'vmbr99' ` + -Confirm:$false ` + -ErrorAction Stop } | Should -Not -Throw + } + + It 'Should revert pending changes (apply to baseline)' { + if (Skip-IfNoTarget) { return } + + # Apply reverts any pending changes back to the running config + { Invoke-PveNetworkApply ` + -Node $script:Node ` + -Wait ` + -ErrorAction Stop } | Should -Not -Throw + } } # -----------------------------------------------------------------------