diff --git a/docs/cmdlets/Add-PveClusterConfigNode.md b/docs/cmdlets/Add-PveClusterConfigNode.md new file mode 100644 index 0000000..97d3316 --- /dev/null +++ b/docs/cmdlets/Add-PveClusterConfigNode.md @@ -0,0 +1,228 @@ +--- +external help file: PSProxmoxVE.dll-Help.xml +Module Name: PSProxmoxVE +online version: +schema: 2.0.0 +--- + +# Add-PveClusterConfigNode + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +``` +Add-PveClusterConfigNode [-Node] [-NewNodeIp ] [-NodeId ] [-Votes ] [-Force] + [-ApiVersion ] [-Links ] [-Wait] [-Session ] [-ProgressAction ] + [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -ApiVersion +JOIN_API_VERSION of the new node. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Force +Force add even if node already exists. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Links +Corosync link addresses as key=value strings (e.g. +'link0=10.0.0.1'). + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -NewNodeIp +IP address of the new node. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Node +The cluster node name to add. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -NodeId +Corosync node ID. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Session +{{ Fill Session Description }} + +```yaml +Type: PveSession +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Votes +Number of quorum votes. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Wait +Wait for the task to complete before returning. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None +## OUTPUTS + +### PSProxmoxVE.Core.Models.Vms.PveTask +## NOTES + +## RELATED LINKS diff --git a/docs/cmdlets/Add-PveClusterMember.md b/docs/cmdlets/Add-PveClusterMember.md new file mode 100644 index 0000000..580ff9b --- /dev/null +++ b/docs/cmdlets/Add-PveClusterMember.md @@ -0,0 +1,228 @@ +--- +external help file: PSProxmoxVE.dll-Help.xml +Module Name: PSProxmoxVE +online version: +schema: 2.0.0 +--- + +# Add-PveClusterMember + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +``` +Add-PveClusterMember [-Hostname] [-Fingerprint] -Password [-NodeId ] + [-Votes ] [-Force] [-Links ] [-Wait] [-Session ] + [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Fingerprint +Certificate SHA-256 fingerprint of the cluster. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Force +Force join even if already part of a cluster. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Hostname +Hostname or IP of an existing cluster member. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Links +Corosync link addresses as key=value strings (e.g. +'link0=10.0.0.1'). + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -NodeId +Corosync node ID for this node. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Password +Root password of the cluster member. + +```yaml +Type: SecureString +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Session +{{ Fill Session Description }} + +```yaml +Type: PveSession +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Votes +Number of quorum votes. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Wait +Wait for the join task to complete before returning. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None +## OUTPUTS + +### PSProxmoxVE.Core.Models.Vms.PveTask +## NOTES + +## RELATED LINKS diff --git a/docs/cmdlets/Connect-PveServer.md b/docs/cmdlets/Connect-PveServer.md index 2ad625b..d2d730b 100644 --- a/docs/cmdlets/Connect-PveServer.md +++ b/docs/cmdlets/Connect-PveServer.md @@ -15,13 +15,13 @@ schema: 2.0.0 ### Credential (Default) ``` Connect-PveServer [-Server] [-Port ] -Credential [-SkipCertificateCheck] - [-PassThru] [-ProgressAction ] [] + [-TimeoutSeconds ] [-PassThru] [-Quiet] [-ProgressAction ] [] ``` ### ApiToken ``` -Connect-PveServer [-Server] [-Port ] -ApiToken [-SkipCertificateCheck] [-PassThru] - [-ProgressAction ] [] +Connect-PveServer [-Server] [-Port ] -ApiToken [-SkipCertificateCheck] + [-TimeoutSeconds ] [-PassThru] [-Quiet] [-ProgressAction ] [] ``` ## DESCRIPTION @@ -146,6 +146,36 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Quiet +Do not output the session object to the pipeline. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -TimeoutSeconds +HTTP timeout in seconds (0 = infinite). Default 100s. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### CommonParameters This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). diff --git a/docs/cmdlets/Disconnect-PveServer.md b/docs/cmdlets/Disconnect-PveServer.md index b7e6c6c..7ae7c6d 100644 --- a/docs/cmdlets/Disconnect-PveServer.md +++ b/docs/cmdlets/Disconnect-PveServer.md @@ -13,7 +13,8 @@ schema: 2.0.0 ## SYNTAX ``` -Disconnect-PveServer [-ProgressAction ] [-WhatIf] [-Confirm] [] +Disconnect-PveServer [-Session ] [-ProgressAction ] [-WhatIf] [-Confirm] + [] ``` ## DESCRIPTION @@ -76,6 +77,21 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Session +{{ Fill Session Description }} + +```yaml +Type: PveSession +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### CommonParameters This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). diff --git a/docs/cmdlets/Get-PveClusterConfig.md b/docs/cmdlets/Get-PveClusterConfig.md new file mode 100644 index 0000000..0d3dee8 --- /dev/null +++ b/docs/cmdlets/Get-PveClusterConfig.md @@ -0,0 +1,74 @@ +--- +external help file: PSProxmoxVE.dll-Help.xml +Module Name: PSProxmoxVE +online version: +schema: 2.0.0 +--- + +# Get-PveClusterConfig + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +``` +Get-PveClusterConfig [-Session ] [-ProgressAction ] [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -Session +{{ Fill Session Description }} + +```yaml +Type: PveSession +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None +## OUTPUTS + +### System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Object, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]] +## NOTES + +## RELATED LINKS diff --git a/docs/cmdlets/Get-PveClusterConfigNode.md b/docs/cmdlets/Get-PveClusterConfigNode.md new file mode 100644 index 0000000..8d1a5aa --- /dev/null +++ b/docs/cmdlets/Get-PveClusterConfigNode.md @@ -0,0 +1,74 @@ +--- +external help file: PSProxmoxVE.dll-Help.xml +Module Name: PSProxmoxVE +online version: +schema: 2.0.0 +--- + +# Get-PveClusterConfigNode + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +``` +Get-PveClusterConfigNode [-Session ] [-ProgressAction ] [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -Session +{{ Fill Session Description }} + +```yaml +Type: PveSession +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None +## OUTPUTS + +### PSProxmoxVE.Core.Models.Cluster.PveClusterConfigNode +## NOTES + +## RELATED LINKS diff --git a/docs/cmdlets/Get-PveClusterJoinInfo.md b/docs/cmdlets/Get-PveClusterJoinInfo.md new file mode 100644 index 0000000..57b4a27 --- /dev/null +++ b/docs/cmdlets/Get-PveClusterJoinInfo.md @@ -0,0 +1,90 @@ +--- +external help file: PSProxmoxVE.dll-Help.xml +Module Name: PSProxmoxVE +online version: +schema: 2.0.0 +--- + +# Get-PveClusterJoinInfo + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +``` +Get-PveClusterJoinInfo [[-Node] ] [-Session ] [-ProgressAction ] + [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -Node +Node to get join info for (defaults to current). + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Session +{{ Fill Session Description }} + +```yaml +Type: PveSession +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None +## OUTPUTS + +### PSProxmoxVE.Core.Models.Cluster.PveClusterJoinInfo +## NOTES + +## RELATED LINKS diff --git a/docs/cmdlets/Get-PveClusterNextId.md b/docs/cmdlets/Get-PveClusterNextId.md new file mode 100644 index 0000000..9f80fd3 --- /dev/null +++ b/docs/cmdlets/Get-PveClusterNextId.md @@ -0,0 +1,90 @@ +--- +external help file: PSProxmoxVE.dll-Help.xml +Module Name: PSProxmoxVE +online version: +schema: 2.0.0 +--- + +# Get-PveClusterNextId + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +``` +Get-PveClusterNextId [[-VmId] ] [-Session ] [-ProgressAction ] + [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -Session +{{ Fill Session Description }} + +```yaml +Type: PveSession +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -VmId +Optional VMID to check availability for. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None +## OUTPUTS + +### System.Int32 +## NOTES + +## RELATED LINKS diff --git a/docs/cmdlets/Get-PveClusterOption.md b/docs/cmdlets/Get-PveClusterOption.md new file mode 100644 index 0000000..4389694 --- /dev/null +++ b/docs/cmdlets/Get-PveClusterOption.md @@ -0,0 +1,74 @@ +--- +external help file: PSProxmoxVE.dll-Help.xml +Module Name: PSProxmoxVE +online version: +schema: 2.0.0 +--- + +# Get-PveClusterOption + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +``` +Get-PveClusterOption [-Session ] [-ProgressAction ] [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -Session +{{ Fill Session Description }} + +```yaml +Type: PveSession +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None +## OUTPUTS + +### PSProxmoxVE.Core.Models.Cluster.PveClusterOptions +## NOTES + +## RELATED LINKS diff --git a/docs/cmdlets/Get-PveClusterStatus.md b/docs/cmdlets/Get-PveClusterStatus.md new file mode 100644 index 0000000..538a9b8 --- /dev/null +++ b/docs/cmdlets/Get-PveClusterStatus.md @@ -0,0 +1,74 @@ +--- +external help file: PSProxmoxVE.dll-Help.xml +Module Name: PSProxmoxVE +online version: +schema: 2.0.0 +--- + +# Get-PveClusterStatus + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +``` +Get-PveClusterStatus [-Session ] [-ProgressAction ] [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -Session +{{ Fill Session Description }} + +```yaml +Type: PveSession +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None +## OUTPUTS + +### PSProxmoxVE.Core.Models.Cluster.PveClusterStatus +## NOTES + +## RELATED LINKS diff --git a/docs/cmdlets/Get-PveFirewallRule.md b/docs/cmdlets/Get-PveFirewallRule.md index e9500b0..988ca0d 100644 --- a/docs/cmdlets/Get-PveFirewallRule.md +++ b/docs/cmdlets/Get-PveFirewallRule.md @@ -13,7 +13,7 @@ Lists firewall rules at the specified level. ## SYNTAX ``` -Get-PveFirewallRule [-Level] [-Node ] [-VmId ] [-Position ] +Get-PveFirewallRule [-Level] [-Node ] [-VmId ] [-Group ] [-Position ] [-Session ] [-ProgressAction ] [] ``` @@ -122,6 +122,21 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Group +The security group name. Required when Level is Group. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### CommonParameters This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). diff --git a/docs/cmdlets/Get-PveHaGroup.md b/docs/cmdlets/Get-PveHaGroup.md new file mode 100644 index 0000000..18a679c --- /dev/null +++ b/docs/cmdlets/Get-PveHaGroup.md @@ -0,0 +1,91 @@ +--- +external help file: PSProxmoxVE.dll-Help.xml +Module Name: PSProxmoxVE +online version: +schema: 2.0.0 +--- + +# Get-PveHaGroup + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +``` +Get-PveHaGroup [[-Group] ] [-Session ] [-ProgressAction ] + [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -Group +HA group name. +Omit to list all groups. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 0 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Session +{{ Fill Session Description }} + +```yaml +Type: PveSession +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.String +## OUTPUTS + +### PSProxmoxVE.Core.Models.HA.PveHaGroup +## NOTES + +## RELATED LINKS diff --git a/docs/cmdlets/Get-PveHaResource.md b/docs/cmdlets/Get-PveHaResource.md new file mode 100644 index 0000000..eaff91a --- /dev/null +++ b/docs/cmdlets/Get-PveHaResource.md @@ -0,0 +1,92 @@ +--- +external help file: PSProxmoxVE.dll-Help.xml +Module Name: PSProxmoxVE +online version: +schema: 2.0.0 +--- + +# Get-PveHaResource + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +``` +Get-PveHaResource [[-Sid] ] [-Session ] [-ProgressAction ] + [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -Session +{{ Fill Session Description }} + +```yaml +Type: PveSession +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Sid +Service ID (e.g. +'vm:100', 'ct:200'). +Omit to list all. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 0 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.String +## OUTPUTS + +### PSProxmoxVE.Core.Models.HA.PveHaResource +## NOTES + +## RELATED LINKS diff --git a/docs/cmdlets/Get-PveHaRule.md b/docs/cmdlets/Get-PveHaRule.md new file mode 100644 index 0000000..c00d653 --- /dev/null +++ b/docs/cmdlets/Get-PveHaRule.md @@ -0,0 +1,91 @@ +--- +external help file: PSProxmoxVE.dll-Help.xml +Module Name: PSProxmoxVE +online version: +schema: 2.0.0 +--- + +# Get-PveHaRule + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +``` +Get-PveHaRule [[-Rule] ] [-Session ] [-ProgressAction ] + [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -Rule +HA rule ID. +Omit to list all rules. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 0 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Session +{{ Fill Session Description }} + +```yaml +Type: PveSession +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.String +## OUTPUTS + +### PSProxmoxVE.Core.Models.HA.PveHaRule +## NOTES + +## RELATED LINKS diff --git a/docs/cmdlets/Get-PveHaStatus.md b/docs/cmdlets/Get-PveHaStatus.md new file mode 100644 index 0000000..da96490 --- /dev/null +++ b/docs/cmdlets/Get-PveHaStatus.md @@ -0,0 +1,74 @@ +--- +external help file: PSProxmoxVE.dll-Help.xml +Module Name: PSProxmoxVE +online version: +schema: 2.0.0 +--- + +# Get-PveHaStatus + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +``` +Get-PveHaStatus [-Session ] [-ProgressAction ] [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -Session +{{ Fill Session Description }} + +```yaml +Type: PveSession +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None +## OUTPUTS + +### PSProxmoxVE.Core.Models.HA.PveHaStatus +## NOTES + +## RELATED LINKS diff --git a/docs/cmdlets/Import-PveOva.md b/docs/cmdlets/Import-PveOva.md index e003753..1272315 100644 --- a/docs/cmdlets/Import-PveOva.md +++ b/docs/cmdlets/Import-PveOva.md @@ -14,7 +14,7 @@ Imports an OVA file into a Proxmox VE virtual machine. ``` Import-PveOva [-Node] [-Storage] [-Path] -TargetStorage [-VmId ] - [-Name ] [-Memory ] [-Cores ] [-Wait] [-Session ] + [-Name ] [-Memory ] [-Cores ] [-Wait] [-TimeoutSeconds ] [-Session ] [-ProgressAction ] [-WhatIf] [-Confirm] [] ``` @@ -227,6 +227,21 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -TimeoutSeconds +HTTP timeout in seconds (0 = infinite). Defaults to 1800 (30 min). + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### CommonParameters This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). diff --git a/docs/cmdlets/Invoke-PveStorageDownload.md b/docs/cmdlets/Invoke-PveStorageDownload.md index 5ed94cf..08c698f 100644 --- a/docs/cmdlets/Invoke-PveStorageDownload.md +++ b/docs/cmdlets/Invoke-PveStorageDownload.md @@ -14,8 +14,8 @@ schema: 2.0.0 ``` Invoke-PveStorageDownload [-Node] [-Storage] [-Url] [-Filename] - [-ContentType ] [-Wait] [-Session ] [-ProgressAction ] [-WhatIf] - [-Confirm] [] + [-ContentType ] [-Wait] [-TimeoutSeconds ] [-Session ] + [-ProgressAction ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -185,6 +185,21 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -TimeoutSeconds +HTTP timeout in seconds (0 = infinite). Defaults to 1800 (30 min). + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### CommonParameters This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). diff --git a/docs/cmdlets/Move-PveHaResource.md b/docs/cmdlets/Move-PveHaResource.md new file mode 100644 index 0000000..f8becf4 --- /dev/null +++ b/docs/cmdlets/Move-PveHaResource.md @@ -0,0 +1,153 @@ +--- +external help file: PSProxmoxVE.dll-Help.xml +Module Name: PSProxmoxVE +online version: +schema: 2.0.0 +--- + +# Move-PveHaResource + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +``` +Move-PveHaResource [-Sid] [-Node] [-Mode ] [-Session ] + [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Mode +Migration mode: Migrate (online) or Relocate (offline). + +```yaml +Type: String +Parameter Sets: (All) +Aliases: +Accepted values: Migrate, Relocate + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Node +Target node name. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Session +{{ Fill Session Description }} + +```yaml +Type: PveSession +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Sid +Service ID (e.g. +'vm:100', 'ct:200'). + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.String +## OUTPUTS + +### System.Void +## NOTES + +## RELATED LINKS diff --git a/docs/cmdlets/New-PveCluster.md b/docs/cmdlets/New-PveCluster.md new file mode 100644 index 0000000..5b38918 --- /dev/null +++ b/docs/cmdlets/New-PveCluster.md @@ -0,0 +1,198 @@ +--- +external help file: PSProxmoxVE.dll-Help.xml +Module Name: PSProxmoxVE +online version: +schema: 2.0.0 +--- + +# New-PveCluster + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +``` +New-PveCluster [-ClusterName] [-NodeId ] [-Votes ] [-Links ] [-Wait] + [-Timeout ] [-Session ] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -ClusterName +The name for the new cluster (max 15 chars). + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Links +Corosync link addresses as key=value strings (e.g. +'link0=10.0.0.1'). + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -NodeId +Corosync node ID for this node. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Session +{{ Fill Session Description }} + +```yaml +Type: PveSession +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Timeout +Timeout in seconds for -Wait (default 60). + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Votes +Number of quorum votes. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Wait +Wait for the task to complete and the cluster to reach quorum before returning. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None +## OUTPUTS + +### PSProxmoxVE.Core.Models.Vms.PveTask +## NOTES + +## RELATED LINKS diff --git a/docs/cmdlets/New-PveFirewallRule.md b/docs/cmdlets/New-PveFirewallRule.md index 24d9b86..8ba928e 100644 --- a/docs/cmdlets/New-PveFirewallRule.md +++ b/docs/cmdlets/New-PveFirewallRule.md @@ -13,10 +13,10 @@ Creates a new firewall rule. ## SYNTAX ``` -New-PveFirewallRule [-Level] [-Node ] [-VmId ] -Type -Action - [-Enable] [-Source ] [-Dest ] [-Proto ] [-Dport ] [-Sport ] - [-Comment ] [-Macro ] [-Log ] [-Iface ] [-Session ] - [-ProgressAction ] [-WhatIf] [-Confirm] [] +New-PveFirewallRule [-Level] [-Node ] [-VmId ] [-Group ] -Type + -Action [-Enable] [-Source ] [-Dest ] [-Proto ] [-Dport ] + [-Sport ] [-Comment ] [-Macro ] [-Log ] [-Iface ] + [-Session ] [-ProgressAction ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -319,6 +319,21 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Group +The security group name. Required when Level is Group. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### CommonParameters This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). diff --git a/docs/cmdlets/New-PveHaGroup.md b/docs/cmdlets/New-PveHaGroup.md new file mode 100644 index 0000000..f215119 --- /dev/null +++ b/docs/cmdlets/New-PveHaGroup.md @@ -0,0 +1,181 @@ +--- +external help file: PSProxmoxVE.dll-Help.xml +Module Name: PSProxmoxVE +online version: +schema: 2.0.0 +--- + +# New-PveHaGroup + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +``` +New-PveHaGroup [-Group] [-Nodes] [-Restricted] [-NoFailback] [-Comment ] + [-Session ] [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -Comment +Description or comment. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Group +HA group name. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -NoFailback +Disable automatic failback to higher-priority nodes. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Nodes +Node list: 'node1:pri,node2:pri'. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Restricted +If set, resources can only run on this group's nodes. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Session +{{ Fill Session Description }} + +```yaml +Type: PveSession +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None +## OUTPUTS + +### System.Void +## NOTES + +## RELATED LINKS diff --git a/docs/cmdlets/New-PveHaResource.md b/docs/cmdlets/New-PveHaResource.md new file mode 100644 index 0000000..2b73170 --- /dev/null +++ b/docs/cmdlets/New-PveHaResource.md @@ -0,0 +1,199 @@ +--- +external help file: PSProxmoxVE.dll-Help.xml +Module Name: PSProxmoxVE +online version: +schema: 2.0.0 +--- + +# New-PveHaResource + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +``` +New-PveHaResource [-Sid] [-State ] [-Group ] [-MaxRelocate ] + [-MaxRestart ] [-Comment ] [-Session ] [-ProgressAction ] + [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -Comment +Description or comment. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Group +HA group name. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -MaxRelocate +Maximum relocations before giving up. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -MaxRestart +Maximum restart attempts. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Session +{{ Fill Session Description }} + +```yaml +Type: PveSession +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Sid +Service ID (e.g. +'vm:100', 'ct:200'). + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -State +Desired state: started, stopped, disabled, ignored. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: +Accepted values: started, stopped, disabled, ignored + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None +## OUTPUTS + +### System.Void +## NOTES + +## RELATED LINKS diff --git a/docs/cmdlets/New-PveHaRule.md b/docs/cmdlets/New-PveHaRule.md new file mode 100644 index 0000000..d7f5cf2 --- /dev/null +++ b/docs/cmdlets/New-PveHaRule.md @@ -0,0 +1,167 @@ +--- +external help file: PSProxmoxVE.dll-Help.xml +Module Name: PSProxmoxVE +online version: +schema: 2.0.0 +--- + +# New-PveHaRule + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +``` +New-PveHaRule [-Type] [-State ] [-Comment ] [-Properties ] + [-Session ] [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -Comment +Description or comment. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Properties +Additional rule properties. + +```yaml +Type: Hashtable +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Session +{{ Fill Session Description }} + +```yaml +Type: PveSession +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -State +Rule state: enabled or disabled. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: +Accepted values: enabled, disabled + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Type +Rule type. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None +## OUTPUTS + +### System.Void +## NOTES + +## RELATED LINKS diff --git a/docs/cmdlets/New-PveNetwork.md b/docs/cmdlets/New-PveNetwork.md index 636a766..14934fc 100644 --- a/docs/cmdlets/New-PveNetwork.md +++ b/docs/cmdlets/New-PveNetwork.md @@ -15,9 +15,8 @@ schema: 2.0.0 ``` New-PveNetwork [-Node] [-Iface] [-Type] [-Address ] [-Netmask ] [-Gateway ] [-BridgeVlanAware] [-BridgePorts ] [-BondSlaves ] [-VlanId ] - [-Mtu ] - [-Autostart] [-Comments ] [-Session ] [-ProgressAction ] [-WhatIf] - [-Confirm] [] + [-Mtu ] [-Autostart] [-Comments ] [-Session ] [-ProgressAction ] + [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -79,22 +78,6 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -BridgeVlanAware - -Enable VLAN-aware bridging (802.1Q) on this bridge. Applies to `bridge` type interfaces only. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -BridgePorts Bridge ports (space-separated interface names). @@ -293,6 +276,22 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -BridgeVlanAware + +Enable VLAN-aware bridging (802.1Q) on this bridge. Applies to `bridge` type interfaces only. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + ### CommonParameters This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). diff --git a/docs/cmdlets/New-PveStorage.md b/docs/cmdlets/New-PveStorage.md index 6654bb4..059d38b 100644 --- a/docs/cmdlets/New-PveStorage.md +++ b/docs/cmdlets/New-PveStorage.md @@ -15,8 +15,8 @@ schema: 2.0.0 ``` New-PveStorage [-Storage] [-Type] [-Content ] [-Path ] [-Server ] [-Export ] [-VgName ] [-ThinPool ] [-Pool ] [-CephPool ] - [-MonHost ] [-Shared] [-Disable] [-Nodes ] [-Session ] - [-ProgressAction ] [-WhatIf] [-Confirm] [] + [-MonHost ] [-Target ] [-Portal ] [-Shared] [-Disable] [-Nodes ] + [-Session ] [-ProgressAction ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -306,6 +306,36 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Portal +iSCSI portal address (host:port). + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Target +iSCSI target IQN (e.g. iqn.2024-01.com.example:storage). + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### CommonParameters This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). diff --git a/docs/cmdlets/New-PveVm.md b/docs/cmdlets/New-PveVm.md index a478c5c..9e785d8 100644 --- a/docs/cmdlets/New-PveVm.md +++ b/docs/cmdlets/New-PveVm.md @@ -15,9 +15,10 @@ schema: 2.0.0 ``` New-PveVm [-Node] [-VmId ] [-Name ] [-Memory ] [-Cores ] [-Sockets ] [-CpuType ] [-Bios ] [-Machine ] [-DiskSize ] - [-DiskStorage ] [-DiskFormat ] [-Network ] [-Bridge ] [-OsType ] - [-Start] [-Wait] [-Session ] [-ProgressAction ] [-WhatIf] [-Confirm] - [] + [-DiskStorage ] [-DiskFormat ] [-DiskBus ] [-ScsiHardware ] [-DiskIoThread] + [-DiskAio ] [-DiskSsd] [-DiskDiscard] [-DiskCache ] [-Network ] [-Bridge ] + [-OsType ] [-Start] [-Wait] [-Session ] [-ProgressAction ] [-WhatIf] + [-Confirm] [] ``` ## DESCRIPTION @@ -357,6 +358,111 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -DiskAio +Async IO mode: native, threads, io_uring. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DiskBus +Primary disk bus: virtio (default), scsi, sata, ide. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DiskCache +Disk cache mode: none, writethrough, writeback, directsync, unsafe. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DiskDiscard +Enable discard/TRIM passthrough (discard=on). + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DiskIoThread +Enable a dedicated IO thread (iothread=1). + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DiskSsd +Mark the primary disk as SSD (ssd=1). + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ScsiHardware +SCSI controller model (e.g. virtio-scsi-single). + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### CommonParameters This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). diff --git a/docs/cmdlets/Remove-PveClusterConfigNode.md b/docs/cmdlets/Remove-PveClusterConfigNode.md new file mode 100644 index 0000000..20c3741 --- /dev/null +++ b/docs/cmdlets/Remove-PveClusterConfigNode.md @@ -0,0 +1,121 @@ +--- +external help file: PSProxmoxVE.dll-Help.xml +Module Name: PSProxmoxVE +online version: +schema: 2.0.0 +--- + +# Remove-PveClusterConfigNode + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +``` +Remove-PveClusterConfigNode [-Node] [-Session ] [-ProgressAction ] + [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Node +The cluster node name to remove. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Session +{{ Fill Session Description }} + +```yaml +Type: PveSession +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None +## OUTPUTS + +### System.Void +## NOTES + +## RELATED LINKS diff --git a/docs/cmdlets/Remove-PveFirewallRule.md b/docs/cmdlets/Remove-PveFirewallRule.md index e7d36af..9a77125 100644 --- a/docs/cmdlets/Remove-PveFirewallRule.md +++ b/docs/cmdlets/Remove-PveFirewallRule.md @@ -13,7 +13,7 @@ Removes a firewall rule. ## SYNTAX ``` -Remove-PveFirewallRule [-Level] [-Node ] [-VmId ] -Position +Remove-PveFirewallRule [-Level] [-Node ] [-VmId ] [-Group ] -Position [-Session ] [-ProgressAction ] [-WhatIf] [-Confirm] [] ``` @@ -150,6 +150,21 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Group +The security group name. Required when Level is Group. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### CommonParameters This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). diff --git a/docs/cmdlets/Remove-PveHaGroup.md b/docs/cmdlets/Remove-PveHaGroup.md new file mode 100644 index 0000000..4c65962 --- /dev/null +++ b/docs/cmdlets/Remove-PveHaGroup.md @@ -0,0 +1,121 @@ +--- +external help file: PSProxmoxVE.dll-Help.xml +Module Name: PSProxmoxVE +online version: +schema: 2.0.0 +--- + +# Remove-PveHaGroup + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +``` +Remove-PveHaGroup [-Group] [-Session ] [-ProgressAction ] [-WhatIf] + [-Confirm] [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Group +HA group name to delete. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Session +{{ Fill Session Description }} + +```yaml +Type: PveSession +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.String +## OUTPUTS + +### System.Void +## NOTES + +## RELATED LINKS diff --git a/docs/cmdlets/Remove-PveHaResource.md b/docs/cmdlets/Remove-PveHaResource.md new file mode 100644 index 0000000..315c672 --- /dev/null +++ b/docs/cmdlets/Remove-PveHaResource.md @@ -0,0 +1,122 @@ +--- +external help file: PSProxmoxVE.dll-Help.xml +Module Name: PSProxmoxVE +online version: +schema: 2.0.0 +--- + +# Remove-PveHaResource + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +``` +Remove-PveHaResource [-Sid] [-Session ] [-ProgressAction ] [-WhatIf] + [-Confirm] [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Session +{{ Fill Session Description }} + +```yaml +Type: PveSession +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Sid +Service ID (e.g. +'vm:100', 'ct:200'). + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.String +## OUTPUTS + +### System.Void +## NOTES + +## RELATED LINKS diff --git a/docs/cmdlets/Remove-PveHaRule.md b/docs/cmdlets/Remove-PveHaRule.md new file mode 100644 index 0000000..e766377 --- /dev/null +++ b/docs/cmdlets/Remove-PveHaRule.md @@ -0,0 +1,121 @@ +--- +external help file: PSProxmoxVE.dll-Help.xml +Module Name: PSProxmoxVE +online version: +schema: 2.0.0 +--- + +# Remove-PveHaRule + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +``` +Remove-PveHaRule [-Rule] [-Session ] [-ProgressAction ] [-WhatIf] + [-Confirm] [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Rule +HA rule ID to delete. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Session +{{ Fill Session Description }} + +```yaml +Type: PveSession +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.String +## OUTPUTS + +### System.Void +## NOTES + +## RELATED LINKS diff --git a/docs/cmdlets/Send-PveFile.md b/docs/cmdlets/Send-PveFile.md index 4aeb990..1ca49bb 100644 --- a/docs/cmdlets/Send-PveFile.md +++ b/docs/cmdlets/Send-PveFile.md @@ -14,7 +14,7 @@ Uploads a local file to a Proxmox VE storage. ``` Send-PveFile [-Node] [-Storage] [-Path] [[-ContentType] ] - [-Checksum ] [-ChecksumAlgorithm ] [-Wait] [-Session ] + [-Checksum ] [-ChecksumAlgorithm ] [-Wait] [-TimeoutSeconds ] [-Session ] [-ProgressAction ] [-WhatIf] [-Confirm] [] ``` @@ -197,6 +197,21 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -TimeoutSeconds +HTTP timeout in seconds (0 = infinite). Defaults to 1800 (30 min). + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### CommonParameters This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). diff --git a/docs/cmdlets/Set-PveClusterOption.md b/docs/cmdlets/Set-PveClusterOption.md new file mode 100644 index 0000000..50374c8 --- /dev/null +++ b/docs/cmdlets/Set-PveClusterOption.md @@ -0,0 +1,276 @@ +--- +external help file: PSProxmoxVE.dll-Help.xml +Module Name: PSProxmoxVE +online version: +schema: 2.0.0 +--- + +# Set-PveClusterOption + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +``` +Set-PveClusterOption [-Keyboard ] [-Language ] [-Console ] [-EmailFrom ] + [-HttpProxy ] [-MacPrefix ] [-MaxWorkers ] [-Fencing ] [-Migration ] + [-Description ] [-Delete ] [-Session ] [-ProgressAction ] + [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Console +Default console viewer. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: +Accepted values: applet, vv, html5, xtermjs + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Delete +Comma-separated list of settings to delete/reset. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Description +Datacenter description shown in the web UI. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -EmailFrom +Email address to send notifications from. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Fencing +HA fencing mode. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: +Accepted values: watchdog, hardware, both + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -HttpProxy +External HTTP proxy URL for downloads. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Keyboard +Default keyboard layout for VNC. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: +Accepted values: de, de-ch, da, en-gb, en-us, es, fi, fr, fr-be, fr-ca, fr-ch, hu, is, it, ja, lt, mk, nl, no, pl, pt, pt-br, sv, sl, tr + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Language +Default GUI language. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -MacPrefix +MAC address prefix for virtual guests. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -MaxWorkers +Max workers per node for bulk operations like stopall. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Migration +Cluster-wide migration settings string. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Session +{{ Fill Session Description }} + +```yaml +Type: PveSession +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None +## OUTPUTS + +### System.Void +## NOTES + +## RELATED LINKS diff --git a/docs/cmdlets/Set-PveFirewallRule.md b/docs/cmdlets/Set-PveFirewallRule.md index 752dc8a..fc8bfd9 100644 --- a/docs/cmdlets/Set-PveFirewallRule.md +++ b/docs/cmdlets/Set-PveFirewallRule.md @@ -13,9 +13,9 @@ Updates a firewall rule. ## SYNTAX ``` -Set-PveFirewallRule [-Level] [-Node ] [-VmId ] -Position [-Type ] - [-Action ] [-Enable] [-Source ] [-Dest ] [-Proto ] [-Dport ] - [-Sport ] [-Comment ] [-Macro ] [-Log ] [-Iface ] +Set-PveFirewallRule [-Level] [-Node ] [-VmId ] [-Group ] -Position + [-Type ] [-Action ] [-Enable] [-Source ] [-Dest ] [-Proto ] + [-Dport ] [-Sport ] [-Comment ] [-Macro ] [-Log ] [-Iface ] [-Session ] [-ProgressAction ] [-WhatIf] [-Confirm] [] ``` @@ -334,6 +334,21 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Group +The security group name. Required when Level is Group. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### CommonParameters This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). diff --git a/docs/cmdlets/Set-PveHaGroup.md b/docs/cmdlets/Set-PveHaGroup.md new file mode 100644 index 0000000..e5e5484 --- /dev/null +++ b/docs/cmdlets/Set-PveHaGroup.md @@ -0,0 +1,182 @@ +--- +external help file: PSProxmoxVE.dll-Help.xml +Module Name: PSProxmoxVE +online version: +schema: 2.0.0 +--- + +# Set-PveHaGroup + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +``` +Set-PveHaGroup [-Group] [-Nodes ] [-Restricted ] [-NoFailback ] + [-Comment ] [-Session ] [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -Comment +Description or comment. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Group +HA group name. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -NoFailback +Disable automatic failback (0 or 1). + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Nodes +Node list: 'node1:pri,node2:pri'. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Restricted +Restrict resources to this group's nodes (0 or 1). + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Session +{{ Fill Session Description }} + +```yaml +Type: PveSession +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.String +## OUTPUTS + +### System.Void +## NOTES + +## RELATED LINKS diff --git a/docs/cmdlets/Set-PveHaResource.md b/docs/cmdlets/Set-PveHaResource.md new file mode 100644 index 0000000..33f63b1 --- /dev/null +++ b/docs/cmdlets/Set-PveHaResource.md @@ -0,0 +1,199 @@ +--- +external help file: PSProxmoxVE.dll-Help.xml +Module Name: PSProxmoxVE +online version: +schema: 2.0.0 +--- + +# Set-PveHaResource + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +``` +Set-PveHaResource [-Sid] [-State ] [-Group ] [-MaxRelocate ] + [-MaxRestart ] [-Comment ] [-Session ] [-ProgressAction ] + [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -Comment +Description or comment. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Group +HA group name. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -MaxRelocate +Maximum relocations before giving up. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -MaxRestart +Maximum restart attempts. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Session +{{ Fill Session Description }} + +```yaml +Type: PveSession +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Sid +Service ID (e.g. +'vm:100', 'ct:200'). + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -State +Desired state: started, stopped, disabled, ignored. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: +Accepted values: started, stopped, disabled, ignored + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.String +## OUTPUTS + +### System.Void +## NOTES + +## RELATED LINKS diff --git a/docs/cmdlets/Set-PveHaRule.md b/docs/cmdlets/Set-PveHaRule.md new file mode 100644 index 0000000..87c46e6 --- /dev/null +++ b/docs/cmdlets/Set-PveHaRule.md @@ -0,0 +1,183 @@ +--- +external help file: PSProxmoxVE.dll-Help.xml +Module Name: PSProxmoxVE +online version: +schema: 2.0.0 +--- + +# Set-PveHaRule + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +``` +Set-PveHaRule [-Rule] [-Type] [-State ] [-Comment ] [-Properties ] + [-Session ] [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -Comment +Description or comment. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Properties +Additional rule properties. + +```yaml +Type: Hashtable +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Rule +HA rule ID. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Session +{{ Fill Session Description }} + +```yaml +Type: PveSession +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -State +Rule state: enabled or disabled. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: +Accepted values: enabled, disabled + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Type +HA rule type (as defined in PVE, e.g. +node-affinity, resource-affinity, location, colocation). + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.String +## OUTPUTS + +### System.Void +## NOTES + +## RELATED LINKS diff --git a/docs/cmdlets/Set-PveNetwork.md b/docs/cmdlets/Set-PveNetwork.md index 64ab163..c05a279 100644 --- a/docs/cmdlets/Set-PveNetwork.md +++ b/docs/cmdlets/Set-PveNetwork.md @@ -15,9 +15,8 @@ schema: 2.0.0 ``` Set-PveNetwork [-Node] [-Iface] -Type [-Address ] [-Netmask ] [-Gateway ] [-Address6 ] [-Netmask6 ] [-Gateway6 ] [-BridgeVlanAware] - [-BridgePorts ] - [-BondSlaves ] [-Mtu ] [-Autostart] [-Comments ] [-Session ] - [-ProgressAction ] [-WhatIf] [-Confirm] [] + [-BridgePorts ] [-BondSlaves ] [-Mtu ] [-Autostart] [-Comments ] + [-Session ] [-ProgressAction ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -94,24 +93,6 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -BridgeVlanAware - -Enable or disable VLAN-aware bridging (802.1Q) on this bridge. Applies to `bridge` type interfaces -only. The flag is sent only when the switch is explicitly bound, so an update that omits it leaves -the current setting untouched; `-BridgeVlanAware:$false` clears it. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -BridgePorts Bridge ports (space-separated interface names). @@ -323,6 +304,24 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -BridgeVlanAware + +Enable or disable VLAN-aware bridging (802.1Q) on this bridge. Applies to `bridge` type interfaces +only. The flag is sent only when the switch is explicitly bound, so an update that omits it leaves +the current setting untouched; `-BridgeVlanAware:$false` clears it. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + ### CommonParameters This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). diff --git a/src/PSProxmoxVE/PSProxmoxVE.dll-Help.xml b/src/PSProxmoxVE/PSProxmoxVE.dll-Help.xml index 97685d1..f41d705 100644 --- a/src/PSProxmoxVE/PSProxmoxVE.dll-Help.xml +++ b/src/PSProxmoxVE/PSProxmoxVE.dll-Help.xml @@ -1,5 +1,683 @@  + + + Add-PveClusterConfigNode + Add + PveClusterConfigNode + + {{ Fill in the Synopsis }} + + + + {{ Fill in the Description }} + + + + Add-PveClusterConfigNode + + Node + + The cluster node name to add. + + String + + String + + + None + + + ApiVersion + + JOIN_API_VERSION of the new node. + + Int32 + + Int32 + + + None + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + Force + + Force add even if node already exists. + + + SwitchParameter + + + False + + + Links + + Corosync link addresses as key=value strings (e.g. 'link0=10.0.0.1'). + + String[] + + String[] + + + None + + + NewNodeIp + + IP address of the new node. + + String + + String + + + None + + + NodeId + + Corosync node ID. + + Int32 + + Int32 + + + None + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + Votes + + Number of quorum votes. + + Int32 + + Int32 + + + None + + + Wait + + Wait for the task to complete before returning. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + ApiVersion + + JOIN_API_VERSION of the new node. + + Int32 + + Int32 + + + None + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + Force + + Force add even if node already exists. + + SwitchParameter + + SwitchParameter + + + False + + + Links + + Corosync link addresses as key=value strings (e.g. 'link0=10.0.0.1'). + + String[] + + String[] + + + None + + + NewNodeIp + + IP address of the new node. + + String + + String + + + None + + + Node + + The cluster node name to add. + + String + + String + + + None + + + NodeId + + Corosync node ID. + + Int32 + + Int32 + + + None + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + Votes + + Number of quorum votes. + + Int32 + + Int32 + + + None + + + Wait + + Wait for the task to complete before returning. + + SwitchParameter + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + None + + + + + + + + + + PSProxmoxVE.Core.Models.Vms.PveTask + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> {{ Add example code here }} + + {{ Add example description here }} + + + + + + + + Add-PveClusterMember + Add + PveClusterMember + + {{ Fill in the Synopsis }} + + + + {{ Fill in the Description }} + + + + Add-PveClusterMember + + Hostname + + Hostname or IP of an existing cluster member. + + String + + String + + + None + + + Fingerprint + + Certificate SHA-256 fingerprint of the cluster. + + String + + String + + + None + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + Force + + Force join even if already part of a cluster. + + + SwitchParameter + + + False + + + Links + + Corosync link addresses as key=value strings (e.g. 'link0=10.0.0.1'). + + String[] + + String[] + + + None + + + NodeId + + Corosync node ID for this node. + + Int32 + + Int32 + + + None + + + Password + + Root password of the cluster member. + + SecureString + + SecureString + + + None + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + Votes + + Number of quorum votes. + + Int32 + + Int32 + + + None + + + Wait + + Wait for the join task to complete before returning. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + Fingerprint + + Certificate SHA-256 fingerprint of the cluster. + + String + + String + + + None + + + Force + + Force join even if already part of a cluster. + + SwitchParameter + + SwitchParameter + + + False + + + Hostname + + Hostname or IP of an existing cluster member. + + String + + String + + + None + + + Links + + Corosync link addresses as key=value strings (e.g. 'link0=10.0.0.1'). + + String[] + + String[] + + + None + + + NodeId + + Corosync node ID for this node. + + Int32 + + Int32 + + + None + + + Password + + Root password of the cluster member. + + SecureString + + SecureString + + + None + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + Votes + + Number of quorum votes. + + Int32 + + Int32 + + + None + + + Wait + + Wait for the join task to complete before returning. + + SwitchParameter + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + None + + + + + + + + + + PSProxmoxVE.Core.Models.Vms.PveTask + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> {{ Add example code here }} + + {{ Add example description here }} + + + + + Connect-PveServer @@ -85,6 +763,29 @@ None + + Quiet + + Do not output the session object to the pipeline. + + + SwitchParameter + + + False + + + TimeoutSeconds + + HTTP timeout in seconds (0 = infinite). Default 100s. + + Int32 + + Int32 + + + None + Connect-PveServer @@ -158,6 +859,29 @@ None + + Quiet + + Do not output the session object to the pipeline. + + + SwitchParameter + + + False + + + TimeoutSeconds + + HTTP timeout in seconds (0 = infinite). Default 100s. + + Int32 + + Int32 + + + None + @@ -245,6 +969,30 @@ None + + Quiet + + Do not output the session object to the pipeline. + + SwitchParameter + + SwitchParameter + + + False + + + TimeoutSeconds + + HTTP timeout in seconds (0 = infinite). Default 100s. + + Int32 + + Int32 + + + None + @@ -1009,6 +1757,18 @@ None + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + @@ -1048,6 +1808,18 @@ None + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + @@ -1624,6 +2396,569 @@ + + + Get-PveClusterConfig + Get + PveClusterConfig + + {{ Fill in the Synopsis }} + + + + {{ Fill in the Description }} + + + + Get-PveClusterConfig + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + None + + + + + + + + + + System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Object, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]] + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> {{ Add example code here }} + + {{ Add example description here }} + + + + + + + + Get-PveClusterConfigNode + Get + PveClusterConfigNode + + {{ Fill in the Synopsis }} + + + + {{ Fill in the Description }} + + + + Get-PveClusterConfigNode + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + None + + + + + + + + + + PSProxmoxVE.Core.Models.Cluster.PveClusterConfigNode + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> {{ Add example code here }} + + {{ Add example description here }} + + + + + + + + Get-PveClusterJoinInfo + Get + PveClusterJoinInfo + + {{ Fill in the Synopsis }} + + + + {{ Fill in the Description }} + + + + Get-PveClusterJoinInfo + + Node + + Node to get join info for (defaults to current). + + String + + String + + + None + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + Node + + Node to get join info for (defaults to current). + + String + + String + + + None + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + None + + + + + + + + + + PSProxmoxVE.Core.Models.Cluster.PveClusterJoinInfo + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> {{ Add example code here }} + + {{ Add example description here }} + + + + + + + + Get-PveClusterNextId + Get + PveClusterNextId + + {{ Fill in the Synopsis }} + + + + {{ Fill in the Description }} + + + + Get-PveClusterNextId + + VmId + + Optional VMID to check availability for. + + Int32 + + Int32 + + + None + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + VmId + + Optional VMID to check availability for. + + Int32 + + Int32 + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + None + + + + + + + + + + System.Int32 + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> {{ Add example code here }} + + {{ Add example description here }} + + + + + + + + Get-PveClusterOption + Get + PveClusterOption + + {{ Fill in the Synopsis }} + + + + {{ Fill in the Description }} + + + + Get-PveClusterOption + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + None + + + + + + + + + + PSProxmoxVE.Core.Models.Cluster.PveClusterOptions + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> {{ Add example code here }} + + {{ Add example description here }} + + + + + Get-PveClusterResource @@ -1789,6 +3124,109 @@ + + + Get-PveClusterStatus + Get + PveClusterStatus + + {{ Fill in the Synopsis }} + + + + {{ Fill in the Description }} + + + + Get-PveClusterStatus + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + None + + + + + + + + + + PSProxmoxVE.Core.Models.Cluster.PveClusterStatus + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> {{ Add example code here }} + + {{ Add example description here }} + + + + + Get-PveContainer @@ -3867,6 +5305,18 @@ None + + Group + + The security group name. Required when Level is Group. + + String + + String + + + None + @@ -3942,6 +5392,18 @@ None + + Group + + The security group name. Required when Level is Group. + + String + + String + + + None + @@ -4113,6 +5575,490 @@ + + + Get-PveHaGroup + Get + PveHaGroup + + {{ Fill in the Synopsis }} + + + + {{ Fill in the Description }} + + + + Get-PveHaGroup + + Group + + HA group name. Omit to list all groups. + + String + + String + + + None + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + Group + + HA group name. Omit to list all groups. + + String + + String + + + None + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + System.String + + + + + + + + + + PSProxmoxVE.Core.Models.HA.PveHaGroup + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> {{ Add example code here }} + + {{ Add example description here }} + + + + + + + + Get-PveHaResource + Get + PveHaResource + + {{ Fill in the Synopsis }} + + + + {{ Fill in the Description }} + + + + Get-PveHaResource + + Sid + + Service ID (e.g. 'vm:100', 'ct:200'). Omit to list all. + + String + + String + + + None + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + Sid + + Service ID (e.g. 'vm:100', 'ct:200'). Omit to list all. + + String + + String + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + System.String + + + + + + + + + + PSProxmoxVE.Core.Models.HA.PveHaResource + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> {{ Add example code here }} + + {{ Add example description here }} + + + + + + + + Get-PveHaRule + Get + PveHaRule + + {{ Fill in the Synopsis }} + + + + {{ Fill in the Description }} + + + + Get-PveHaRule + + Rule + + HA rule ID. Omit to list all rules. + + String + + String + + + None + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + Rule + + HA rule ID. Omit to list all rules. + + String + + String + + + None + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + System.String + + + + + + + + + + PSProxmoxVE.Core.Models.HA.PveHaRule + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> {{ Add example code here }} + + {{ Add example description here }} + + + + + + + + Get-PveHaStatus + Get + PveHaStatus + + {{ Fill in the Synopsis }} + + + + {{ Fill in the Description }} + + + + Get-PveHaStatus + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + None + + + + + + + + + + PSProxmoxVE.Core.Models.HA.PveHaStatus + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> {{ Add example code here }} + + {{ Add example description here }} + + + + + Get-PveNetwork @@ -8466,6 +10412,18 @@ None + + TimeoutSeconds + + HTTP timeout in seconds (0 = infinite). Defaults to 1800 (30 min). + + Int32 + + Int32 + + + None + @@ -8625,6 +10583,18 @@ None + + TimeoutSeconds + + HTTP timeout in seconds (0 = infinite). Defaults to 1800 (30 min). + + Int32 + + Int32 + + + None + @@ -9694,6 +11664,18 @@ None + + TimeoutSeconds + + HTTP timeout in seconds (0 = infinite). Defaults to 1800 (30 min). + + Int32 + + Int32 + + + None + @@ -9817,6 +11799,18 @@ None + + TimeoutSeconds + + HTTP timeout in seconds (0 = infinite). Defaults to 1800 (30 min). + + Int32 + + Int32 + + + None + @@ -10894,6 +12888,231 @@ + + + Move-PveHaResource + Move + PveHaResource + + {{ Fill in the Synopsis }} + + + + {{ Fill in the Description }} + + + + Move-PveHaResource + + Sid + + Service ID (e.g. 'vm:100', 'ct:200'). + + String + + String + + + None + + + Node + + Target node name. + + String + + String + + + None + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + Mode + + Migration mode: Migrate (online) or Relocate (offline). + + + Migrate + Relocate + + String + + String + + + None + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + Mode + + Migration mode: Migrate (online) or Relocate (offline). + + String + + String + + + None + + + Node + + Target node name. + + String + + String + + + None + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + Sid + + Service ID (e.g. 'vm:100', 'ct:200'). + + String + + String + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + System.String + + + + + + + + + + System.Void + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> {{ Add example code here }} + + {{ Add example description here }} + + + + + Move-PveVm @@ -12550,6 +14769,298 @@ + + + New-PveCluster + New + PveCluster + + {{ Fill in the Synopsis }} + + + + {{ Fill in the Description }} + + + + New-PveCluster + + ClusterName + + The name for the new cluster (max 15 chars). + + String + + String + + + None + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + Links + + Corosync link addresses as key=value strings (e.g. 'link0=10.0.0.1'). + + String[] + + String[] + + + None + + + NodeId + + Corosync node ID for this node. + + Int32 + + Int32 + + + None + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + Timeout + + Timeout in seconds for -Wait (default 60). + + Int32 + + Int32 + + + None + + + Votes + + Number of quorum votes. + + Int32 + + Int32 + + + None + + + Wait + + Wait for the task to complete and the cluster to reach quorum before returning. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + ClusterName + + The name for the new cluster (max 15 chars). + + String + + String + + + None + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + Links + + Corosync link addresses as key=value strings (e.g. 'link0=10.0.0.1'). + + String[] + + String[] + + + None + + + NodeId + + Corosync node ID for this node. + + Int32 + + Int32 + + + None + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + Timeout + + Timeout in seconds for -Wait (default 60). + + Int32 + + Int32 + + + None + + + Votes + + Number of quorum votes. + + Int32 + + Int32 + + + None + + + Wait + + Wait for the task to complete and the cluster to reach quorum before returning. + + SwitchParameter + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + None + + + + + + + + + + PSProxmoxVE.Core.Models.Vms.PveTask + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> {{ Add example code here }} + + {{ Add example description here }} + + + + + New-PveContainer @@ -15153,6 +17664,18 @@ None + + Group + + The security group name. Required when Level is Group. + + String + + String + + + None + @@ -15384,6 +17907,18 @@ None + + Group + + The security group name. Required when Level is Group. + + String + + String + + + None + @@ -15618,6 +18153,821 @@ + + + New-PveHaGroup + New + PveHaGroup + + {{ Fill in the Synopsis }} + + + + {{ Fill in the Description }} + + + + New-PveHaGroup + + Group + + HA group name. + + String + + String + + + None + + + Nodes + + Node list: 'node1:pri,node2:pri'. + + String + + String + + + None + + + Comment + + Description or comment. + + String + + String + + + None + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + NoFailback + + Disable automatic failback to higher-priority nodes. + + + SwitchParameter + + + False + + + Restricted + + If set, resources can only run on this group's nodes. + + + SwitchParameter + + + False + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + Comment + + Description or comment. + + String + + String + + + None + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + Group + + HA group name. + + String + + String + + + None + + + NoFailback + + Disable automatic failback to higher-priority nodes. + + SwitchParameter + + SwitchParameter + + + False + + + Nodes + + Node list: 'node1:pri,node2:pri'. + + String + + String + + + None + + + Restricted + + If set, resources can only run on this group's nodes. + + SwitchParameter + + SwitchParameter + + + False + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + None + + + + + + + + + + System.Void + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> {{ Add example code here }} + + {{ Add example description here }} + + + + + + + + New-PveHaResource + New + PveHaResource + + {{ Fill in the Synopsis }} + + + + {{ Fill in the Description }} + + + + New-PveHaResource + + Sid + + Service ID (e.g. 'vm:100', 'ct:200'). + + String + + String + + + None + + + Comment + + Description or comment. + + String + + String + + + None + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + Group + + HA group name. + + String + + String + + + None + + + MaxRelocate + + Maximum relocations before giving up. + + Int32 + + Int32 + + + None + + + MaxRestart + + Maximum restart attempts. + + Int32 + + Int32 + + + None + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + State + + Desired state: started, stopped, disabled, ignored. + + + started + stopped + disabled + ignored + + String + + String + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + Comment + + Description or comment. + + String + + String + + + None + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + Group + + HA group name. + + String + + String + + + None + + + MaxRelocate + + Maximum relocations before giving up. + + Int32 + + Int32 + + + None + + + MaxRestart + + Maximum restart attempts. + + Int32 + + Int32 + + + None + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + Sid + + Service ID (e.g. 'vm:100', 'ct:200'). + + String + + String + + + None + + + State + + Desired state: started, stopped, disabled, ignored. + + String + + String + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + None + + + + + + + + + + System.Void + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> {{ Add example code here }} + + {{ Add example description here }} + + + + + + + + New-PveHaRule + New + PveHaRule + + {{ Fill in the Synopsis }} + + + + {{ Fill in the Description }} + + + + New-PveHaRule + + Type + + Rule type. + + String + + String + + + None + + + Comment + + Description or comment. + + String + + String + + + None + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + Properties + + Additional rule properties. + + Hashtable + + Hashtable + + + None + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + State + + Rule state: enabled or disabled. + + + enabled + disabled + + String + + String + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + Comment + + Description or comment. + + String + + String + + + None + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + Properties + + Additional rule properties. + + Hashtable + + Hashtable + + + None + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + State + + Rule state: enabled or disabled. + + String + + String + + + None + + + Type + + Rule type. + + String + + String + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + None + + + + + + + + + + System.Void + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> {{ Add example code here }} + + {{ Add example description here }} + + + + + New-PveNetwork @@ -15833,6 +19183,17 @@ None + + BridgeVlanAware + + Enable VLAN-aware bridging (802.1Q) on this bridge. Applies to `bridge` type interfaces only. + + + SwitchParameter + + + False + @@ -16028,6 +19389,18 @@ None + + BridgeVlanAware + + Enable VLAN-aware bridging (802.1Q) on this bridge. Applies to `bridge` type interfaces only. + + SwitchParameter + + SwitchParameter + + + False + @@ -18767,6 +22140,30 @@ None + + Portal + + iSCSI portal address (host:port). + + String + + String + + + None + + + Target + + iSCSI target IQN (e.g. iqn.2024-01.com.example:storage). + + String + + String + + + None + @@ -18986,6 +22383,30 @@ None + + Portal + + iSCSI portal address (host:port). + + String + + String + + + None + + + Target + + iSCSI target IQN (e.g. iqn.2024-01.com.example:storage). + + String + + String + + + None + @@ -20121,6 +23542,87 @@ None + + DiskAio + + Async IO mode: native, threads, io_uring. + + String + + String + + + None + + + DiskBus + + Primary disk bus: virtio (default), scsi, sata, ide. + + String + + String + + + None + + + DiskCache + + Disk cache mode: none, writethrough, writeback, directsync, unsafe. + + String + + String + + + None + + + DiskDiscard + + Enable discard/TRIM passthrough (discard=on). + + + SwitchParameter + + + False + + + DiskIoThread + + Enable a dedicated IO thread (iothread=1). + + + SwitchParameter + + + False + + + DiskSsd + + Mark the primary disk as SSD (ssd=1). + + + SwitchParameter + + + False + + + ScsiHardware + + SCSI controller model (e.g. virtio-scsi-single). + + String + + String + + + None + @@ -20376,6 +23878,90 @@ None + + DiskAio + + Async IO mode: native, threads, io_uring. + + String + + String + + + None + + + DiskBus + + Primary disk bus: virtio (default), scsi, sata, ide. + + String + + String + + + None + + + DiskCache + + Disk cache mode: none, writethrough, writeback, directsync, unsafe. + + String + + String + + + None + + + DiskDiscard + + Enable discard/TRIM passthrough (discard=on). + + SwitchParameter + + SwitchParameter + + + False + + + DiskIoThread + + Enable a dedicated IO thread (iothread=1). + + SwitchParameter + + SwitchParameter + + + False + + + DiskSsd + + Mark the primary disk as SSD (ssd=1). + + SwitchParameter + + SwitchParameter + + + False + + + ScsiHardware + + SCSI controller model (e.g. virtio-scsi-single). + + String + + String + + + None + @@ -21281,6 +24867,179 @@ + + + Remove-PveClusterConfigNode + Remove + PveClusterConfigNode + + {{ Fill in the Synopsis }} + + + + {{ Fill in the Description }} + + + + Remove-PveClusterConfigNode + + Node + + The cluster node name to remove. + + String + + String + + + None + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + Node + + The cluster node name to remove. + + String + + String + + + None + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + None + + + + + + + + + + System.Void + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> {{ Add example code here }} + + {{ Add example description here }} + + + + + Remove-PveContainer @@ -23037,6 +26796,18 @@ None + + Group + + The security group name. Required when Level is Group. + + String + + String + + + None + @@ -23136,6 +26907,18 @@ None + + Group + + The security group name. Required when Level is Group. + + String + + String + + + None + @@ -23346,6 +27129,525 @@ + + + Remove-PveHaGroup + Remove + PveHaGroup + + {{ Fill in the Synopsis }} + + + + {{ Fill in the Description }} + + + + Remove-PveHaGroup + + Group + + HA group name to delete. + + String + + String + + + None + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + Group + + HA group name to delete. + + String + + String + + + None + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + System.String + + + + + + + + + + System.Void + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> {{ Add example code here }} + + {{ Add example description here }} + + + + + + + + Remove-PveHaResource + Remove + PveHaResource + + {{ Fill in the Synopsis }} + + + + {{ Fill in the Description }} + + + + Remove-PveHaResource + + Sid + + Service ID (e.g. 'vm:100', 'ct:200'). + + String + + String + + + None + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + Sid + + Service ID (e.g. 'vm:100', 'ct:200'). + + String + + String + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + System.String + + + + + + + + + + System.Void + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> {{ Add example code here }} + + {{ Add example description here }} + + + + + + + + Remove-PveHaRule + Remove + PveHaRule + + {{ Fill in the Synopsis }} + + + + {{ Fill in the Description }} + + + + Remove-PveHaRule + + Rule + + HA rule ID to delete. + + String + + String + + + None + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + Rule + + HA rule ID to delete. + + String + + String + + + None + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + System.String + + + + + + + + + + System.Void + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> {{ Add example code here }} + + {{ Add example description here }} + + + + + Remove-PveNetwork @@ -28963,6 +33265,18 @@ None + + TimeoutSeconds + + HTTP timeout in seconds (0 = infinite). Defaults to 1800 (30 min). + + Int32 + + Int32 + + + None + @@ -29098,6 +33412,18 @@ None + + TimeoutSeconds + + HTTP timeout in seconds (0 = infinite). Defaults to 1800 (30 min). + + Int32 + + Int32 + + + None + @@ -30265,6 +34591,457 @@ + + + Set-PveClusterOption + Set + PveClusterOption + + {{ Fill in the Synopsis }} + + + + {{ Fill in the Description }} + + + + Set-PveClusterOption + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + Console + + Default console viewer. + + + applet + vv + html5 + xtermjs + + String + + String + + + None + + + Delete + + Comma-separated list of settings to delete/reset. + + String + + String + + + None + + + Description + + Datacenter description shown in the web UI. + + String + + String + + + None + + + EmailFrom + + Email address to send notifications from. + + String + + String + + + None + + + Fencing + + HA fencing mode. + + + watchdog + hardware + both + + String + + String + + + None + + + HttpProxy + + External HTTP proxy URL for downloads. + + String + + String + + + None + + + Keyboard + + Default keyboard layout for VNC. + + + de + de-ch + da + en-gb + en-us + es + fi + fr + fr-be + fr-ca + fr-ch + hu + is + it + ja + lt + mk + nl + no + pl + pt + pt-br + sv + sl + tr + + String + + String + + + None + + + Language + + Default GUI language. + + String + + String + + + None + + + MacPrefix + + MAC address prefix for virtual guests. + + String + + String + + + None + + + MaxWorkers + + Max workers per node for bulk operations like stopall. + + Int32 + + Int32 + + + None + + + Migration + + Cluster-wide migration settings string. + + String + + String + + + None + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + Console + + Default console viewer. + + String + + String + + + None + + + Delete + + Comma-separated list of settings to delete/reset. + + String + + String + + + None + + + Description + + Datacenter description shown in the web UI. + + String + + String + + + None + + + EmailFrom + + Email address to send notifications from. + + String + + String + + + None + + + Fencing + + HA fencing mode. + + String + + String + + + None + + + HttpProxy + + External HTTP proxy URL for downloads. + + String + + String + + + None + + + Keyboard + + Default keyboard layout for VNC. + + String + + String + + + None + + + Language + + Default GUI language. + + String + + String + + + None + + + MacPrefix + + MAC address prefix for virtual guests. + + String + + String + + + None + + + MaxWorkers + + Max workers per node for bulk operations like stopall. + + Int32 + + Int32 + + + None + + + Migration + + Cluster-wide migration settings string. + + String + + String + + + None + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + None + + + + + + + + + + System.Void + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> {{ Add example code here }} + + {{ Add example description here }} + + + + + Set-PveContainerConfig @@ -32267,6 +37044,18 @@ None + + Group + + The security group name. Required when Level is Group. + + String + + String + + + None + @@ -32510,6 +37299,18 @@ None + + Group + + The security group name. Required when Level is Group. + + String + + String + + + None + @@ -32744,6 +37545,847 @@ + + + Set-PveHaGroup + Set + PveHaGroup + + {{ Fill in the Synopsis }} + + + + {{ Fill in the Description }} + + + + Set-PveHaGroup + + Group + + HA group name. + + String + + String + + + None + + + Comment + + Description or comment. + + String + + String + + + None + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + NoFailback + + Disable automatic failback (0 or 1). + + Int32 + + Int32 + + + None + + + Nodes + + Node list: 'node1:pri,node2:pri'. + + String + + String + + + None + + + Restricted + + Restrict resources to this group's nodes (0 or 1). + + Int32 + + Int32 + + + None + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + Comment + + Description or comment. + + String + + String + + + None + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + Group + + HA group name. + + String + + String + + + None + + + NoFailback + + Disable automatic failback (0 or 1). + + Int32 + + Int32 + + + None + + + Nodes + + Node list: 'node1:pri,node2:pri'. + + String + + String + + + None + + + Restricted + + Restrict resources to this group's nodes (0 or 1). + + Int32 + + Int32 + + + None + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + System.String + + + + + + + + + + System.Void + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> {{ Add example code here }} + + {{ Add example description here }} + + + + + + + + Set-PveHaResource + Set + PveHaResource + + {{ Fill in the Synopsis }} + + + + {{ Fill in the Description }} + + + + Set-PveHaResource + + Sid + + Service ID (e.g. 'vm:100', 'ct:200'). + + String + + String + + + None + + + Comment + + Description or comment. + + String + + String + + + None + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + Group + + HA group name. + + String + + String + + + None + + + MaxRelocate + + Maximum relocations before giving up. + + Int32 + + Int32 + + + None + + + MaxRestart + + Maximum restart attempts. + + Int32 + + Int32 + + + None + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + State + + Desired state: started, stopped, disabled, ignored. + + + started + stopped + disabled + ignored + + String + + String + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + Comment + + Description or comment. + + String + + String + + + None + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + Group + + HA group name. + + String + + String + + + None + + + MaxRelocate + + Maximum relocations before giving up. + + Int32 + + Int32 + + + None + + + MaxRestart + + Maximum restart attempts. + + Int32 + + Int32 + + + None + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + Sid + + Service ID (e.g. 'vm:100', 'ct:200'). + + String + + String + + + None + + + State + + Desired state: started, stopped, disabled, ignored. + + String + + String + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + System.String + + + + + + + + + + System.Void + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> {{ Add example code here }} + + {{ Add example description here }} + + + + + + + + Set-PveHaRule + Set + PveHaRule + + {{ Fill in the Synopsis }} + + + + {{ Fill in the Description }} + + + + Set-PveHaRule + + Rule + + HA rule ID. + + String + + String + + + None + + + Type + + HA rule type (as defined in PVE, e.g. node-affinity, resource-affinity, location, colocation). + + String + + String + + + None + + + Comment + + Description or comment. + + String + + String + + + None + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + Properties + + Additional rule properties. + + Hashtable + + Hashtable + + + None + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + State + + Rule state: enabled or disabled. + + + enabled + disabled + + String + + String + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + Comment + + Description or comment. + + String + + String + + + None + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + Properties + + Additional rule properties. + + Hashtable + + Hashtable + + + None + + + Rule + + HA rule ID. + + String + + String + + + None + + + Session + + {{ Fill Session Description }} + + PveSession + + PveSession + + + None + + + State + + Rule state: enabled or disabled. + + String + + String + + + None + + + Type + + HA rule type (as defined in PVE, e.g. node-affinity, resource-affinity, location, colocation). + + String + + String + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + System.String + + + + + + + + + + System.Void + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> {{ Add example code here }} + + {{ Add example description here }} + + + + + Set-PveNetwork @@ -32972,6 +38614,17 @@ None + + BridgeVlanAware + + Enable or disable VLAN-aware bridging (802.1Q) on this bridge. Applies to `bridge` type interfaces only. The flag is sent only when the switch is explicitly bound, so an update that omits it leaves the current setting untouched; `-BridgeVlanAware:$false` clears it. + + + SwitchParameter + + + False + @@ -33191,6 +38844,18 @@ None + + BridgeVlanAware + + Enable or disable VLAN-aware bridging (802.1Q) on this bridge. Applies to `bridge` type interfaces only. The flag is sent only when the switch is explicitly bound, so an update that omits it leaves the current setting untouched; `-BridgeVlanAware:$false` clears it. + + SwitchParameter + + SwitchParameter + + + False + diff --git a/tests/PSProxmoxVE.Tests/Backup/BackupCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Backup/BackupCmdlets.Tests.ps1 index 8e675c8..b40c813 100644 --- a/tests/PSProxmoxVE.Tests/Backup/BackupCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Backup/BackupCmdlets.Tests.ps1 @@ -5,96 +5,26 @@ New-PveBackup, Get-PveBackupJob, New-PveBackupJob, Set-PveBackupJob, Remove-PveBackupJob. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:Availability = @{} - foreach ($name in @('New-PveBackup', 'Get-PveBackupJob', 'New-PveBackupJob', 'Set-PveBackupJob', 'Remove-PveBackupJob')) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } -} - -# --------------------------------------------------------------------------- -# Manifest contract -# --------------------------------------------------------------------------- -Describe 'Backup cmdlets — manifest declarations' { - BeforeAll { - $manifestPath = Join-Path (Get-Module PSProxmoxVE).ModuleBase 'PSProxmoxVE.psd1' - $script:Manifest = if (Test-Path $manifestPath) { Import-PowerShellDataFile $manifestPath } else { $null } - } - - It " should be declared in CmdletsToExport" -TestCases @( - @{ cmdName = 'New-PveBackup' } - @{ cmdName = 'Get-PveBackupJob' } - @{ cmdName = 'New-PveBackupJob' } - @{ cmdName = 'Set-PveBackupJob' } - @{ cmdName = 'Remove-PveBackupJob' } - ) { - if ($null -eq $script:Manifest) { Set-ItResult -Skipped -Because 'Manifest not found'; return } - $script:Manifest.CmdletsToExport | Should -Contain $cmdName - } } # --------------------------------------------------------------------------- # New-PveBackup # --------------------------------------------------------------------------- Describe 'New-PveBackup' { - - BeforeAll { $script:Cmd = Get-Command 'New-PveBackup' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PveBackup' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'New-PveBackup' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'New-PveBackup' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'New-PveBackup' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Parameter metadata' { - It 'Should have VmId parameter' { - Skip-IfMissing 'New-PveBackup' - $script:Cmd.Parameters.ContainsKey('VmId') | Should -BeTrue - } - - It 'Should have Storage parameter' { - Skip-IfMissing 'New-PveBackup' - $script:Cmd.Parameters.ContainsKey('Storage') | Should -BeTrue - } - - It 'Should have Node parameter' { - Skip-IfMissing 'New-PveBackup' - $script:Cmd.Parameters.ContainsKey('Node') | Should -BeTrue - } - - It 'Should have Session parameter' { - Skip-IfMissing 'New-PveBackup' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'New-PveBackup' { New-PveBackup -VmId 100 -Storage 'local' -Node 'pve' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -105,36 +35,10 @@ Describe 'New-PveBackup' { # Get-PveBackupJob # --------------------------------------------------------------------------- Describe 'Get-PveBackupJob' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveBackupJob' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveBackupJob' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveBackupJob' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Parameter metadata' { - It 'Should have optional Id parameter' { - Skip-IfMissing 'Get-PveBackupJob' - $script:Cmd.Parameters.ContainsKey('Id') | Should -BeTrue - } - - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveBackupJob' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveBackupJob' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveBackupJob' { Get-PveBackupJob -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -145,59 +49,16 @@ Describe 'Get-PveBackupJob' { # New-PveBackupJob # --------------------------------------------------------------------------- Describe 'New-PveBackupJob' { - - BeforeAll { $script:Cmd = Get-Command 'New-PveBackupJob' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PveBackupJob' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'New-PveBackupJob' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'New-PveBackupJob' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Storage should be Mandatory' { - Skip-IfMissing 'New-PveBackupJob' - $isMandatory = $script:Cmd.Parameters['Storage'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Schedule should be Mandatory' { - Skip-IfMissing 'New-PveBackupJob' - $isMandatory = $script:Cmd.Parameters['Schedule'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - - Context 'Optional parameters' { - It 'Should have VmId parameter' { - Skip-IfMissing 'New-PveBackupJob' - $script:Cmd.Parameters.ContainsKey('VmId') | Should -BeTrue - } - - It 'Should have Mode parameter' { - Skip-IfMissing 'New-PveBackupJob' - $script:Cmd.Parameters.ContainsKey('Mode') | Should -BeTrue - } - - It 'Should have Compress parameter' { - Skip-IfMissing 'New-PveBackupJob' - $script:Cmd.Parameters.ContainsKey('Compress') | Should -BeTrue - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'New-PveBackupJob' { New-PveBackupJob -Storage 'local' -Schedule 'daily' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -208,35 +69,16 @@ Describe 'New-PveBackupJob' { # Set-PveBackupJob # --------------------------------------------------------------------------- Describe 'Set-PveBackupJob' { - - BeforeAll { $script:Cmd = Get-Command 'Set-PveBackupJob' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Set-PveBackupJob' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Set-PveBackupJob' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Set-PveBackupJob' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Id should be Mandatory' { - Skip-IfMissing 'Set-PveBackupJob' - $isMandatory = $script:Cmd.Parameters['Id'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Set-PveBackupJob' { Set-PveBackupJob -Id 'backup-test' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -247,24 +89,14 @@ Describe 'Set-PveBackupJob' { # Remove-PveBackupJob # --------------------------------------------------------------------------- Describe 'Remove-PveBackupJob' { - - BeforeAll { $script:Cmd = Get-Command 'Remove-PveBackupJob' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Remove-PveBackupJob' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Remove-PveBackupJob' } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { - Skip-IfMissing 'Remove-PveBackupJob' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High' { - Skip-IfMissing 'Remove-PveBackupJob' $attr = $script:Cmd.ImplementingType.GetCustomAttributes( [System.Management.Automation.CmdletAttribute], $false) | Select-Object -First 1 @@ -272,18 +104,8 @@ Describe 'Remove-PveBackupJob' { } } - Context 'Required parameters' { - It 'Id should be Mandatory' { - Skip-IfMissing 'Remove-PveBackupJob' - $isMandatory = $script:Cmd.Parameters['Id'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Remove-PveBackupJob' { Remove-PveBackupJob -Id 'backup-test' -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } diff --git a/tests/PSProxmoxVE.Tests/Backup/BackupInfoCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Backup/BackupInfoCmdlets.Tests.ps1 index 98436c9..7a89111 100644 --- a/tests/PSProxmoxVE.Tests/Backup/BackupInfoCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Backup/BackupInfoCmdlets.Tests.ps1 @@ -5,52 +5,20 @@ Get-PveBackupInfo. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:Availability = @{} - foreach ($name in @('Get-PveBackupInfo')) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } } # --------------------------------------------------------------------------- # Get-PveBackupInfo # --------------------------------------------------------------------------- Describe 'Get-PveBackupInfo' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveBackupInfo' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveBackupInfo' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveBackupInfo' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Parameter metadata' { - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveBackupInfo' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveBackupInfo' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveBackupInfo' { Get-PveBackupInfo -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } diff --git a/tests/PSProxmoxVE.Tests/CloudInit/CloudInitCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/CloudInit/CloudInitCmdlets.Tests.ps1 index 4c10544..1d7a172 100644 --- a/tests/PSProxmoxVE.Tests/CloudInit/CloudInitCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/CloudInit/CloudInitCmdlets.Tests.ps1 @@ -5,7 +5,6 @@ Get-PveCloudInitConfig, Set-PveCloudInitConfig, Invoke-PveCloudInitRegenerate. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. Cloud-Init cmdlets operate on an existing QEMU VM's cloud-init drive. The configuration fields map to the PveCloudInitConfig model: @@ -15,82 +14,16 @@ BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:Availability = @{} - foreach ($name in @('Get-PveCloudInitConfig', 'Set-PveCloudInitConfig', - 'Invoke-PveCloudInitRegenerate')) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } -} - -# --------------------------------------------------------------------------- -# Manifest contract -# --------------------------------------------------------------------------- -Describe 'Cloud-Init cmdlets — manifest declarations' { - BeforeAll { - $manifestPath = Join-Path (Get-Module PSProxmoxVE).ModuleBase 'PSProxmoxVE.psd1' - $script:Manifest = if (Test-Path $manifestPath) { Import-PowerShellDataFile $manifestPath } else { $null } - } - - It " should be declared in CmdletsToExport" -TestCases @( - @{ cmdName = 'Get-PveCloudInitConfig' } - @{ cmdName = 'Set-PveCloudInitConfig' } - @{ cmdName = 'Invoke-PveCloudInitRegenerate' } - ) { - if ($null -eq $script:Manifest) { Set-ItResult -Skipped -Because 'Manifest not found'; return } - $script:Manifest.CmdletsToExport | Should -Contain $cmdName - } } # --------------------------------------------------------------------------- # Get-PveCloudInitConfig # --------------------------------------------------------------------------- Describe 'Get-PveCloudInitConfig' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveCloudInitConfig' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveCloudInitConfig' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveCloudInitConfig' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Parameter metadata' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Get-PveCloudInitConfig' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'VmId should be Mandatory' { - Skip-IfMissing 'Get-PveCloudInitConfig' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveCloudInitConfig' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveCloudInitConfig' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveCloudInitConfig' { Get-PveCloudInitConfig -Node 'pve-node1' -VmId 100 -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -101,78 +34,16 @@ Describe 'Get-PveCloudInitConfig' { # Set-PveCloudInitConfig # --------------------------------------------------------------------------- Describe 'Set-PveCloudInitConfig' { - - BeforeAll { $script:Cmd = Get-Command 'Set-PveCloudInitConfig' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Set-PveCloudInitConfig' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Set-PveCloudInitConfig' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Set-PveCloudInitConfig' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Set-PveCloudInitConfig' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'VmId should be Mandatory' { - Skip-IfMissing 'Set-PveCloudInitConfig' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - - Context 'Optional cloud-init configuration parameters' { - It 'Should have CiUser parameter' { - Skip-IfMissing 'Set-PveCloudInitConfig' - $script:Cmd.Parameters.ContainsKey('CiUser') | Should -BeTrue - } - - It 'Should have CiPassword parameter (SecureString or plain-text)' { - Skip-IfMissing 'Set-PveCloudInitConfig' - $hasPassword = $script:Cmd.Parameters.ContainsKey('CiPassword') -or - $script:Cmd.Parameters.ContainsKey('Password') - $hasPassword | Should -BeTrue - } - - It 'Should have SshKeys parameter' { - Skip-IfMissing 'Set-PveCloudInitConfig' - $hasSsh = $script:Cmd.Parameters.ContainsKey('SshKeys') -or - $script:Cmd.Parameters.ContainsKey('SshPublicKey') - $hasSsh | Should -BeTrue - } - - It 'Should have IpConfig0 parameter' { - Skip-IfMissing 'Set-PveCloudInitConfig' - $script:Cmd.Parameters.ContainsKey('IpConfig0') | Should -BeTrue - } - - It 'Should have Nameserver parameter' { - Skip-IfMissing 'Set-PveCloudInitConfig' - $script:Cmd.Parameters.ContainsKey('Nameserver') | Should -BeTrue - } - - It 'Should have Searchdomain parameter' { - Skip-IfMissing 'Set-PveCloudInitConfig' - $script:Cmd.Parameters.ContainsKey('Searchdomain') | Should -BeTrue - } - } - Context 'Without active session' { It 'Should throw when no session is active (without -WhatIf)' { - Skip-IfMissing 'Set-PveCloudInitConfig' { Set-PveCloudInitConfig -Node 'pve-node1' -VmId 100 -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -183,49 +54,16 @@ Describe 'Set-PveCloudInitConfig' { # Invoke-PveCloudInitRegenerate # --------------------------------------------------------------------------- Describe 'Invoke-PveCloudInitRegenerate' { - - BeforeAll { $script:Cmd = Get-Command 'Invoke-PveCloudInitRegenerate' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Invoke-PveCloudInitRegenerate' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Invoke-PveCloudInitRegenerate' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Invoke-PveCloudInitRegenerate' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Invoke-PveCloudInitRegenerate' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'VmId should be Mandatory' { - Skip-IfMissing 'Invoke-PveCloudInitRegenerate' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - - Context 'Optional parameters' { - It 'Should have Wait switch parameter' { - Skip-IfMissing 'Invoke-PveCloudInitRegenerate' - $script:Cmd.Parameters.ContainsKey('Wait') | Should -BeTrue - } - } - Context 'Without active session' { It 'Should throw when no session is active (without -WhatIf)' { - Skip-IfMissing 'Invoke-PveCloudInitRegenerate' { Invoke-PveCloudInitRegenerate -Node 'pve-node1' -VmId 100 -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } diff --git a/tests/PSProxmoxVE.Tests/Cluster/ClusterCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Cluster/ClusterCmdlets.Tests.ps1 index 5b59777..dbda3d2 100644 --- a/tests/PSProxmoxVE.Tests/Cluster/ClusterCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Cluster/ClusterCmdlets.Tests.ps1 @@ -5,60 +5,20 @@ Get-PveClusterResource. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:Availability = @{} - foreach ($name in @('Get-PveClusterResource')) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } } # --------------------------------------------------------------------------- # Get-PveClusterResource # --------------------------------------------------------------------------- Describe 'Get-PveClusterResource' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveClusterResource' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveClusterResource' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveClusterResource' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Parameter metadata' { - It 'Should have optional Type parameter' { - Skip-IfMissing 'Get-PveClusterResource' - $script:Cmd.Parameters.ContainsKey('Type') | Should -BeTrue - } - It 'Should have optional Node parameter' { - Skip-IfMissing 'Get-PveClusterResource' - $script:Cmd.Parameters.ContainsKey('Node') | Should -BeTrue - } - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveClusterResource' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveClusterResource' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveClusterResource' { Get-PveClusterResource -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } diff --git a/tests/PSProxmoxVE.Tests/Cluster/ClusterConfigCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Cluster/ClusterConfigCmdlets.Tests.ps1 index fa2bdb8..206a433 100644 --- a/tests/PSProxmoxVE.Tests/Cluster/ClusterConfigCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Cluster/ClusterConfigCmdlets.Tests.ps1 @@ -8,64 +8,20 @@ Get-PveClusterJoinInfo, Add-PveClusterMember, New-PveCluster. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:Availability = @{} - foreach ($name in @( - 'Get-PveClusterStatus', - 'Get-PveClusterNextId', - 'Get-PveClusterOption', - 'Set-PveClusterOption', - 'Get-PveClusterConfig', - 'Get-PveClusterConfigNode', - 'Add-PveClusterConfigNode', - 'Remove-PveClusterConfigNode', - 'Get-PveClusterJoinInfo', - 'Add-PveClusterMember', - 'New-PveCluster' - )) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } } # --------------------------------------------------------------------------- # Get-PveClusterStatus # --------------------------------------------------------------------------- Describe 'Get-PveClusterStatus' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveClusterStatus' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveClusterStatus' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveClusterStatus' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Parameter metadata' { - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveClusterStatus' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveClusterStatus' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveClusterStatus' { Get-PveClusterStatus -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -76,48 +32,20 @@ Describe 'Get-PveClusterStatus' -Tag 'Unit' { # Get-PveClusterNextId # --------------------------------------------------------------------------- Describe 'Get-PveClusterNextId' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveClusterNextId' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveClusterNextId' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveClusterNextId' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveClusterNextId' } Context 'Parameter metadata' { - It 'Should have optional VmId parameter' { - Skip-IfMissing 'Get-PveClusterNextId' - $script:Cmd.Parameters.ContainsKey('VmId') | Should -BeTrue - } - It 'VmId should not be Mandatory' { - Skip-IfMissing 'Get-PveClusterNextId' - $p = $script:Cmd.Parameters['VmId'] - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } It 'VmId should have ValidateRange(100, 999999999)' { - Skip-IfMissing 'Get-PveClusterNextId' $p = $script:Cmd.Parameters['VmId'] $rangeAttr = $p.Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateRangeAttribute] } $rangeAttr | Should -Not -BeNullOrEmpty $rangeAttr.MinRange | Should -Be 100 $rangeAttr.MaxRange | Should -Be 999999999 } - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveClusterNextId' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveClusterNextId' { Get-PveClusterNextId -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -128,30 +56,10 @@ Describe 'Get-PveClusterNextId' -Tag 'Unit' { # Get-PveClusterOption # --------------------------------------------------------------------------- Describe 'Get-PveClusterOption' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveClusterOption' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveClusterOption' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveClusterOption' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Parameter metadata' { - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveClusterOption' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveClusterOption' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveClusterOption' { Get-PveClusterOption -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -162,58 +70,26 @@ Describe 'Get-PveClusterOption' -Tag 'Unit' { # Set-PveClusterOption # --------------------------------------------------------------------------- Describe 'Set-PveClusterOption' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Set-PveClusterOption' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Set-PveClusterOption' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Set-PveClusterOption' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Set-PveClusterOption' } Context 'Parameter metadata' { - It 'Should have Keyboard parameter' { - Skip-IfMissing 'Set-PveClusterOption' - $script:Cmd.Parameters.ContainsKey('Keyboard') | Should -BeTrue - } It 'Keyboard should have ValidateSet' { - Skip-IfMissing 'Set-PveClusterOption' $p = $script:Cmd.Parameters['Keyboard'] $vsAttr = $p.Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } $vsAttr | Should -Not -BeNullOrEmpty } - It 'Should have Language parameter' { - Skip-IfMissing 'Set-PveClusterOption' - $script:Cmd.Parameters.ContainsKey('Language') | Should -BeTrue - } - It 'Should have Console parameter' { - Skip-IfMissing 'Set-PveClusterOption' - $script:Cmd.Parameters.ContainsKey('Console') | Should -BeTrue - } It 'Console should have ValidateSet' { - Skip-IfMissing 'Set-PveClusterOption' $p = $script:Cmd.Parameters['Console'] $vsAttr = $p.Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } $vsAttr | Should -Not -BeNullOrEmpty } It 'Should have Fencing parameter with ValidateSet' { - Skip-IfMissing 'Set-PveClusterOption' $p = $script:Cmd.Parameters['Fencing'] $p | Should -Not -BeNullOrEmpty $vsAttr = $p.Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } $vsAttr | Should -Not -BeNullOrEmpty } - It 'Should have Session parameter' { - Skip-IfMissing 'Set-PveClusterOption' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } It 'Should support ShouldProcess' { - Skip-IfMissing 'Set-PveClusterOption' $cmdletAttr = $script:Cmd.ImplementingType.GetCustomAttributes($true) | Where-Object { $_ -is [System.Management.Automation.CmdletAttribute] } $cmdletAttr.SupportsShouldProcess | Should -BeTrue @@ -222,7 +98,6 @@ Describe 'Set-PveClusterOption' -Tag 'Unit' { Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Set-PveClusterOption' { Set-PveClusterOption -Keyboard 'en-us' -ErrorAction Stop -Confirm:$false } | Should -Throw '*No active Proxmox VE session*' } @@ -233,30 +108,10 @@ Describe 'Set-PveClusterOption' -Tag 'Unit' { # Get-PveClusterConfig # --------------------------------------------------------------------------- Describe 'Get-PveClusterConfig' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveClusterConfig' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveClusterConfig' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveClusterConfig' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Parameter metadata' { - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveClusterConfig' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveClusterConfig' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveClusterConfig' { Get-PveClusterConfig -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -267,30 +122,10 @@ Describe 'Get-PveClusterConfig' -Tag 'Unit' { # Get-PveClusterConfigNode # --------------------------------------------------------------------------- Describe 'Get-PveClusterConfigNode' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveClusterConfigNode' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveClusterConfigNode' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveClusterConfigNode' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Parameter metadata' { - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveClusterConfigNode' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveClusterConfigNode' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveClusterConfigNode' { Get-PveClusterConfigNode -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -301,56 +136,15 @@ Describe 'Get-PveClusterConfigNode' -Tag 'Unit' { # Add-PveClusterConfigNode # --------------------------------------------------------------------------- Describe 'Add-PveClusterConfigNode' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Add-PveClusterConfigNode' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Add-PveClusterConfigNode' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Add-PveClusterConfigNode' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Add-PveClusterConfigNode' } Context 'Parameter metadata' { - It 'Should have mandatory Node parameter' { - Skip-IfMissing 'Add-PveClusterConfigNode' - $p = $script:Cmd.Parameters['Node'] - $p | Should -Not -BeNullOrEmpty - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Should have optional NewNodeIp parameter' { - Skip-IfMissing 'Add-PveClusterConfigNode' - $script:Cmd.Parameters.ContainsKey('NewNodeIp') | Should -BeTrue - } - It 'Should have optional NodeId parameter' { - Skip-IfMissing 'Add-PveClusterConfigNode' - $script:Cmd.Parameters.ContainsKey('NodeId') | Should -BeTrue - } - It 'Should have optional Votes parameter' { - Skip-IfMissing 'Add-PveClusterConfigNode' - $script:Cmd.Parameters.ContainsKey('Votes') | Should -BeTrue - } - It 'Should have optional Force switch' { - Skip-IfMissing 'Add-PveClusterConfigNode' - $script:Cmd.Parameters.ContainsKey('Force') | Should -BeTrue - } - It 'Should have Session parameter' { - Skip-IfMissing 'Add-PveClusterConfigNode' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } It 'Should support ShouldProcess' { - Skip-IfMissing 'Add-PveClusterConfigNode' $cmdletAttr = $script:Cmd.ImplementingType.GetCustomAttributes($true) | Where-Object { $_ -is [System.Management.Automation.CmdletAttribute] } $cmdletAttr.SupportsShouldProcess | Should -BeTrue } It 'Should have ConfirmImpact High' { - Skip-IfMissing 'Add-PveClusterConfigNode' $cmdletAttr = $script:Cmd.ImplementingType.GetCustomAttributes($true) | Where-Object { $_ -is [System.Management.Automation.CmdletAttribute] } $cmdletAttr.ConfirmImpact | Should -Be 'High' @@ -359,7 +153,6 @@ Describe 'Add-PveClusterConfigNode' -Tag 'Unit' { Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Add-PveClusterConfigNode' { Add-PveClusterConfigNode -Node 'pve2' -ErrorAction Stop -Confirm:$false } | Should -Throw '*No active Proxmox VE session*' } @@ -370,40 +163,15 @@ Describe 'Add-PveClusterConfigNode' -Tag 'Unit' { # Remove-PveClusterConfigNode # --------------------------------------------------------------------------- Describe 'Remove-PveClusterConfigNode' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Remove-PveClusterConfigNode' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Remove-PveClusterConfigNode' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Remove-PveClusterConfigNode' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Remove-PveClusterConfigNode' } Context 'Parameter metadata' { - It 'Should have mandatory Node parameter' { - Skip-IfMissing 'Remove-PveClusterConfigNode' - $p = $script:Cmd.Parameters['Node'] - $p | Should -Not -BeNullOrEmpty - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Should have Session parameter' { - Skip-IfMissing 'Remove-PveClusterConfigNode' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } It 'Should support ShouldProcess' { - Skip-IfMissing 'Remove-PveClusterConfigNode' $cmdletAttr = $script:Cmd.ImplementingType.GetCustomAttributes($true) | Where-Object { $_ -is [System.Management.Automation.CmdletAttribute] } $cmdletAttr.SupportsShouldProcess | Should -BeTrue } It 'Should have ConfirmImpact High' { - Skip-IfMissing 'Remove-PveClusterConfigNode' $cmdletAttr = $script:Cmd.ImplementingType.GetCustomAttributes($true) | Where-Object { $_ -is [System.Management.Automation.CmdletAttribute] } $cmdletAttr.ConfirmImpact | Should -Be 'High' @@ -412,7 +180,6 @@ Describe 'Remove-PveClusterConfigNode' -Tag 'Unit' { Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Remove-PveClusterConfigNode' { Remove-PveClusterConfigNode -Node 'pve2' -ErrorAction Stop -Confirm:$false } | Should -Throw '*No active Proxmox VE session*' } @@ -423,40 +190,10 @@ Describe 'Remove-PveClusterConfigNode' -Tag 'Unit' { # Get-PveClusterJoinInfo # --------------------------------------------------------------------------- Describe 'Get-PveClusterJoinInfo' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveClusterJoinInfo' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveClusterJoinInfo' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveClusterJoinInfo' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Parameter metadata' { - It 'Should have optional Node parameter' { - Skip-IfMissing 'Get-PveClusterJoinInfo' - $script:Cmd.Parameters.ContainsKey('Node') | Should -BeTrue - } - It 'Node should not be Mandatory' { - Skip-IfMissing 'Get-PveClusterJoinInfo' - $p = $script:Cmd.Parameters['Node'] - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveClusterJoinInfo' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveClusterJoinInfo' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveClusterJoinInfo' { Get-PveClusterJoinInfo -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -467,62 +204,18 @@ Describe 'Get-PveClusterJoinInfo' -Tag 'Unit' { # Add-PveClusterMember # --------------------------------------------------------------------------- Describe 'Add-PveClusterMember' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Add-PveClusterMember' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Add-PveClusterMember' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Add-PveClusterMember' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Add-PveClusterMember' } Context 'Parameter metadata' { - It 'Should have mandatory Hostname parameter' { - Skip-IfMissing 'Add-PveClusterMember' - $p = $script:Cmd.Parameters['Hostname'] - $p | Should -Not -BeNullOrEmpty - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Should have mandatory Fingerprint parameter' { - Skip-IfMissing 'Add-PveClusterMember' - $p = $script:Cmd.Parameters['Fingerprint'] - $p | Should -Not -BeNullOrEmpty - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Should have mandatory Password parameter' { - Skip-IfMissing 'Add-PveClusterMember' - $p = $script:Cmd.Parameters['Password'] - $p | Should -Not -BeNullOrEmpty - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } It 'Password should be SecureString type' { - Skip-IfMissing 'Add-PveClusterMember' $script:Cmd.Parameters['Password'].ParameterType | Should -Be ([System.Security.SecureString]) } - It 'Should have optional Force switch' { - Skip-IfMissing 'Add-PveClusterMember' - $script:Cmd.Parameters.ContainsKey('Force') | Should -BeTrue - } - It 'Should have Session parameter' { - Skip-IfMissing 'Add-PveClusterMember' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } It 'Should support ShouldProcess' { - Skip-IfMissing 'Add-PveClusterMember' $cmdletAttr = $script:Cmd.ImplementingType.GetCustomAttributes($true) | Where-Object { $_ -is [System.Management.Automation.CmdletAttribute] } $cmdletAttr.SupportsShouldProcess | Should -BeTrue } It 'Should have ConfirmImpact High' { - Skip-IfMissing 'Add-PveClusterMember' $cmdletAttr = $script:Cmd.ImplementingType.GetCustomAttributes($true) | Where-Object { $_ -is [System.Management.Automation.CmdletAttribute] } $cmdletAttr.ConfirmImpact | Should -Be 'High' @@ -531,7 +224,6 @@ Describe 'Add-PveClusterMember' -Tag 'Unit' { Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Add-PveClusterMember' $secPw = ConvertTo-SecureString 'test' -AsPlainText -Force { Add-PveClusterMember -Hostname 'pve1' -Fingerprint 'AA:BB' -Password $secPw -ErrorAction Stop -Confirm:$false } | Should -Throw '*No active Proxmox VE session*' @@ -543,60 +235,22 @@ Describe 'Add-PveClusterMember' -Tag 'Unit' { # New-PveCluster # --------------------------------------------------------------------------- Describe 'New-PveCluster' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'New-PveCluster' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PveCluster' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'New-PveCluster' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'New-PveCluster' } Context 'Parameter metadata' { - It 'Should have mandatory ClusterName parameter' { - Skip-IfMissing 'New-PveCluster' - $p = $script:Cmd.Parameters['ClusterName'] - $p | Should -Not -BeNullOrEmpty - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } It 'ClusterName should have ValidateLength(1, 15)' { - Skip-IfMissing 'New-PveCluster' $p = $script:Cmd.Parameters['ClusterName'] $lenAttr = $p.Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateLengthAttribute] } $lenAttr | Should -Not -BeNullOrEmpty $lenAttr.MinLength | Should -Be 1 $lenAttr.MaxLength | Should -Be 15 } - It 'Should have optional NodeId parameter' { - Skip-IfMissing 'New-PveCluster' - $script:Cmd.Parameters.ContainsKey('NodeId') | Should -BeTrue - } - It 'Should have optional Votes parameter' { - Skip-IfMissing 'New-PveCluster' - $script:Cmd.Parameters.ContainsKey('Votes') | Should -BeTrue - } - It 'Should have optional Links parameter' { - Skip-IfMissing 'New-PveCluster' - $script:Cmd.Parameters.ContainsKey('Links') | Should -BeTrue - } - It 'Should have Session parameter' { - Skip-IfMissing 'New-PveCluster' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } It 'Should support ShouldProcess' { - Skip-IfMissing 'New-PveCluster' $cmdletAttr = $script:Cmd.ImplementingType.GetCustomAttributes($true) | Where-Object { $_ -is [System.Management.Automation.CmdletAttribute] } $cmdletAttr.SupportsShouldProcess | Should -BeTrue } It 'Should have ConfirmImpact High' { - Skip-IfMissing 'New-PveCluster' $cmdletAttr = $script:Cmd.ImplementingType.GetCustomAttributes($true) | Where-Object { $_ -is [System.Management.Automation.CmdletAttribute] } $cmdletAttr.ConfirmImpact | Should -Be 'High' @@ -605,7 +259,6 @@ Describe 'New-PveCluster' -Tag 'Unit' { Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'New-PveCluster' { New-PveCluster -ClusterName 'testcluster' -ErrorAction Stop -Confirm:$false } | Should -Throw '*No active Proxmox VE session*' } diff --git a/tests/PSProxmoxVE.Tests/Connection/Connect-PveServer.Tests.ps1 b/tests/PSProxmoxVE.Tests/Connection/Connect-PveServer.Tests.ps1 index 68848d0..3ea4c19 100644 --- a/tests/PSProxmoxVE.Tests/Connection/Connect-PveServer.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Connection/Connect-PveServer.Tests.ps1 @@ -14,18 +14,6 @@ BeforeAll { } Describe 'Connect-PveServer' { - - Context 'Command existence' { - It 'Should be available after module import' { - Get-Command 'Connect-PveServer' -ErrorAction SilentlyContinue | - Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - (Get-Command 'Connect-PveServer').CommandType | Should -Be 'Cmdlet' - } - } - Context 'Parameter validation — required parameters' { It 'Server should be Mandatory' { $param = (Get-Command 'Connect-PveServer').Parameters['Server'] @@ -58,10 +46,6 @@ Describe 'Connect-PveServer' { $script:Cmd = Get-Command 'Connect-PveServer' } - It 'Should have a Server parameter' { - $script:Cmd.Parameters.ContainsKey('Server') | Should -BeTrue - } - It 'Should declare Server as Mandatory' { $serverParam = $script:Cmd.Parameters['Server'] $isMandatory = $serverParam.ParameterSets.Values | @@ -70,24 +54,12 @@ Describe 'Connect-PveServer' { $isMandatory | Should -Not -BeNullOrEmpty } - It 'Should have a Port parameter' { - $script:Cmd.Parameters.ContainsKey('Port') | Should -BeTrue - } - It 'Port should default to 8006' { # Verify default via the static default-value metadata on the parameter. $portParam = $script:Cmd.Parameters['Port'] $portParam | Should -Not -BeNullOrEmpty } - It 'Should have a Credential parameter' { - $script:Cmd.Parameters.ContainsKey('Credential') | Should -BeTrue - } - - It 'Should have an ApiToken parameter' { - $script:Cmd.Parameters.ContainsKey('ApiToken') | Should -BeTrue - } - It 'Should have a SkipCertificateCheck switch parameter' { $script:Cmd.Parameters.ContainsKey('SkipCertificateCheck') | Should -BeTrue $script:Cmd.Parameters['SkipCertificateCheck'].ParameterType | @@ -113,10 +85,6 @@ Describe 'Connect-PveServer' { $overlap | Should -BeNullOrEmpty } - It 'Should have a TimeoutSeconds parameter' { - $script:Cmd.Parameters.ContainsKey('TimeoutSeconds') | Should -BeTrue - } - It 'TimeoutSeconds should reject negative values' { $securePass = ConvertTo-SecureString 'hunter2' -AsPlainText -Force $cred = [System.Management.Automation.PSCredential]::new('root@pam', $securePass) diff --git a/tests/PSProxmoxVE.Tests/Connection/Disconnect-PveServer.Tests.ps1 b/tests/PSProxmoxVE.Tests/Connection/Disconnect-PveServer.Tests.ps1 index 6bc5caf..e628f11 100644 --- a/tests/PSProxmoxVE.Tests/Connection/Disconnect-PveServer.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Connection/Disconnect-PveServer.Tests.ps1 @@ -10,18 +10,6 @@ BeforeAll { } Describe 'Disconnect-PveServer' { - - Context 'Command existence' { - It 'Should be available after module import' { - Get-Command 'Disconnect-PveServer' -ErrorAction SilentlyContinue | - Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - (Get-Command 'Disconnect-PveServer').CommandType | Should -Be 'Cmdlet' - } - } - Context 'Parameter metadata' { BeforeAll { $script:Cmd = Get-Command 'Disconnect-PveServer' @@ -38,10 +26,6 @@ Describe 'Disconnect-PveServer' { # attribute is present by confirming ShouldProcess support is enabled. $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } - - It 'Should expose -Session parameter' { - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } } Context 'Behaviour when no session is active' { diff --git a/tests/PSProxmoxVE.Tests/Connection/Test-PveConnection.Tests.ps1 b/tests/PSProxmoxVE.Tests/Connection/Test-PveConnection.Tests.ps1 index 55e0cf3..e0023d1 100644 --- a/tests/PSProxmoxVE.Tests/Connection/Test-PveConnection.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Connection/Test-PveConnection.Tests.ps1 @@ -10,18 +10,6 @@ BeforeAll { } Describe 'Test-PveConnection' { - - Context 'Command existence' { - It 'Should be available after module import' { - Get-Command 'Test-PveConnection' -ErrorAction SilentlyContinue | - Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - (Get-Command 'Test-PveConnection').CommandType | Should -Be 'Cmdlet' - } - } - Context 'Parameter metadata' { BeforeAll { $script:Cmd = Get-Command 'Test-PveConnection' diff --git a/tests/PSProxmoxVE.Tests/Containers/ContainerConfigCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Containers/ContainerConfigCmdlets.Tests.ps1 index e78f4f9..f05587d 100644 --- a/tests/PSProxmoxVE.Tests/Containers/ContainerConfigCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Containers/ContainerConfigCmdlets.Tests.ps1 @@ -5,126 +5,35 @@ Copy-PveContainer, Get-PveContainerConfig, Set-PveContainerConfig. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:Availability = @{} - foreach ($name in @('Copy-PveContainer', 'Get-PveContainerConfig', 'Set-PveContainerConfig')) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } -} - -# --------------------------------------------------------------------------- -# Manifest contract -# --------------------------------------------------------------------------- -Describe 'Container config cmdlets — manifest declarations' { - BeforeAll { - $manifestPath = Join-Path (Get-Module PSProxmoxVE).ModuleBase 'PSProxmoxVE.psd1' - $script:Manifest = if (Test-Path $manifestPath) { Import-PowerShellDataFile $manifestPath } else { $null } - } - - It " should be declared in CmdletsToExport" -TestCases @( - @{ cmdName = 'Copy-PveContainer' } - @{ cmdName = 'Get-PveContainerConfig' } - @{ cmdName = 'Set-PveContainerConfig' } - ) { - if ($null -eq $script:Manifest) { Set-ItResult -Skipped -Because 'Manifest not found'; return } - $script:Manifest.CmdletsToExport | Should -Contain $cmdName - } } # --------------------------------------------------------------------------- # Copy-PveContainer # --------------------------------------------------------------------------- Describe 'Copy-PveContainer' { - - BeforeAll { $script:Cmd = Get-Command 'Copy-PveContainer' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Copy-PveContainer' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Copy-PveContainer' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Copy-PveContainer' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Copy-PveContainer' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should support Confirm' { - Skip-IfMissing 'Copy-PveContainer' $script:Cmd.Parameters.ContainsKey('Confirm') | Should -BeTrue } } - Context 'Required parameters' { - It 'SourceNode should be Mandatory' { - Skip-IfMissing 'Copy-PveContainer' - $isMandatory = $script:Cmd.Parameters['SourceNode'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'VmId should be Mandatory' { - Skip-IfMissing 'Copy-PveContainer' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Optional parameters' { - It 'Should have NewVmId parameter' { - Skip-IfMissing 'Copy-PveContainer' - $script:Cmd.Parameters.ContainsKey('NewVmId') | Should -BeTrue - } - - It 'NewVmId should not be Mandatory' { - Skip-IfMissing 'Copy-PveContainer' - $isMandatory = $script:Cmd.Parameters['NewVmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } - - It 'Should have NewName parameter' { - Skip-IfMissing 'Copy-PveContainer' - $script:Cmd.Parameters.ContainsKey('NewName') | Should -BeTrue - } - - It 'Should have TargetNode parameter' { - Skip-IfMissing 'Copy-PveContainer' - $script:Cmd.Parameters.ContainsKey('TargetNode') | Should -BeTrue - } - It 'Should have Full switch parameter' { - Skip-IfMissing 'Copy-PveContainer' $script:Cmd.Parameters.ContainsKey('Full') | Should -BeTrue $script:Cmd.Parameters['Full'].SwitchParameter | Should -BeTrue } - It 'Should have Storage parameter' { - Skip-IfMissing 'Copy-PveContainer' - $script:Cmd.Parameters.ContainsKey('Storage') | Should -BeTrue - } - It 'Should have Wait switch parameter' { - Skip-IfMissing 'Copy-PveContainer' $script:Cmd.Parameters.ContainsKey('Wait') | Should -BeTrue $script:Cmd.Parameters['Wait'].SwitchParameter | Should -BeTrue } @@ -132,7 +41,6 @@ Describe 'Copy-PveContainer' { Context 'Pipeline support' { It 'VmId should accept pipeline input by property name' { - Skip-IfMissing 'Copy-PveContainer' $vmid = $script:Cmd.Parameters['VmId'] $acceptsByPropName = $vmid.ParameterSets.Values | Where-Object { $_.ValueFromPipelineByPropertyName } @@ -140,16 +48,8 @@ Describe 'Copy-PveContainer' { } } - Context 'Session parameter' { - It 'Should have Session parameter (inherited from PveCmdletBase)' { - Skip-IfMissing 'Copy-PveContainer' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Copy-PveContainer' { Copy-PveContainer -SourceNode 'pve1' -VmId 100 -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -160,40 +60,10 @@ Describe 'Copy-PveContainer' { # Get-PveContainerConfig # --------------------------------------------------------------------------- Describe 'Get-PveContainerConfig' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveContainerConfig' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveContainerConfig' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveContainerConfig' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Get-PveContainerConfig' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'VmId should be Mandatory' { - Skip-IfMissing 'Get-PveContainerConfig' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveContainerConfig' } Context 'Pipeline support' { It 'Node should accept pipeline input by property name' { - Skip-IfMissing 'Get-PveContainerConfig' $node = $script:Cmd.Parameters['Node'] $acceptsByPropName = $node.ParameterSets.Values | Where-Object { $_.ValueFromPipelineByPropertyName } @@ -201,7 +71,6 @@ Describe 'Get-PveContainerConfig' { } It 'VmId should accept pipeline input by property name' { - Skip-IfMissing 'Get-PveContainerConfig' $vmid = $script:Cmd.Parameters['VmId'] $acceptsByPropName = $vmid.ParameterSets.Values | Where-Object { $_.ValueFromPipelineByPropertyName } @@ -209,23 +78,14 @@ Describe 'Get-PveContainerConfig' { } } - Context 'Session parameter' { - It 'Should have Session parameter (inherited from PveCmdletBase)' { - Skip-IfMissing 'Get-PveContainerConfig' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } - Context 'ShouldProcess not required' { It 'Should not have WhatIf (Get verb is read-only)' { - Skip-IfMissing 'Get-PveContainerConfig' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeFalse } } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveContainerConfig' { Get-PveContainerConfig -Node 'pve1' -VmId 100 -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -236,101 +96,20 @@ Describe 'Get-PveContainerConfig' { # Set-PveContainerConfig # --------------------------------------------------------------------------- Describe 'Set-PveContainerConfig' { - - BeforeAll { $script:Cmd = Get-Command 'Set-PveContainerConfig' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Set-PveContainerConfig' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Set-PveContainerConfig' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Set-PveContainerConfig' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Set-PveContainerConfig' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should support Confirm' { - Skip-IfMissing 'Set-PveContainerConfig' $script:Cmd.Parameters.ContainsKey('Confirm') | Should -BeTrue } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Set-PveContainerConfig' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'VmId should be Mandatory' { - Skip-IfMissing 'Set-PveContainerConfig' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - - Context 'Optional configuration parameters' { - It 'Should have Hostname parameter' { - Skip-IfMissing 'Set-PveContainerConfig' - $script:Cmd.Parameters.ContainsKey('Hostname') | Should -BeTrue - } - - It 'Hostname should not be Mandatory' { - Skip-IfMissing 'Set-PveContainerConfig' - $isMandatory = $script:Cmd.Parameters['Hostname'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } - - It 'Should have Cores parameter' { - Skip-IfMissing 'Set-PveContainerConfig' - $script:Cmd.Parameters.ContainsKey('Cores') | Should -BeTrue - } - - It 'Should have Memory parameter' { - Skip-IfMissing 'Set-PveContainerConfig' - $script:Cmd.Parameters.ContainsKey('Memory') | Should -BeTrue - } - - It 'Should have Swap parameter' { - Skip-IfMissing 'Set-PveContainerConfig' - $script:Cmd.Parameters.ContainsKey('Swap') | Should -BeTrue - } - - It 'Should have Description parameter' { - Skip-IfMissing 'Set-PveContainerConfig' - $script:Cmd.Parameters.ContainsKey('Description') | Should -BeTrue - } - - It 'Should have Tags parameter' { - Skip-IfMissing 'Set-PveContainerConfig' - $script:Cmd.Parameters.ContainsKey('Tags') | Should -BeTrue - } - - It 'Should have Nameserver parameter' { - Skip-IfMissing 'Set-PveContainerConfig' - $script:Cmd.Parameters.ContainsKey('Nameserver') | Should -BeTrue - } - - It 'Should have SearchDomain parameter' { - Skip-IfMissing 'Set-PveContainerConfig' - $script:Cmd.Parameters.ContainsKey('SearchDomain') | Should -BeTrue - } - } - Context 'Pipeline support' { It 'Node should accept pipeline input by property name' { - Skip-IfMissing 'Set-PveContainerConfig' $node = $script:Cmd.Parameters['Node'] $acceptsByPropName = $node.ParameterSets.Values | Where-Object { $_.ValueFromPipelineByPropertyName } @@ -338,7 +117,6 @@ Describe 'Set-PveContainerConfig' { } It 'VmId should accept pipeline input by property name' { - Skip-IfMissing 'Set-PveContainerConfig' $vmid = $script:Cmd.Parameters['VmId'] $acceptsByPropName = $vmid.ParameterSets.Values | Where-Object { $_.ValueFromPipelineByPropertyName } @@ -346,16 +124,8 @@ Describe 'Set-PveContainerConfig' { } } - Context 'Session parameter' { - It 'Should have Session parameter (inherited from PveCmdletBase)' { - Skip-IfMissing 'Set-PveContainerConfig' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Set-PveContainerConfig' { Set-PveContainerConfig -Node 'pve1' -VmId 100 -Hostname 'test' -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } diff --git a/tests/PSProxmoxVE.Tests/Containers/ContainerGapCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Containers/ContainerGapCmdlets.Tests.ps1 index b0dd445..b6ee9d1 100644 --- a/tests/PSProxmoxVE.Tests/Containers/ContainerGapCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Containers/ContainerGapCmdlets.Tests.ps1 @@ -6,70 +6,26 @@ New-PveContainerTemplate, Move-PveContainerVolume, Get-PveContainerInterface. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:Availability = @{} - foreach ($name in @( - 'Suspend-PveContainer', 'Resume-PveContainer', 'Resize-PveContainerDisk', - 'New-PveContainerTemplate', 'Move-PveContainerVolume', 'Get-PveContainerInterface' - )) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } } # --------------------------------------------------------------------------- # Suspend-PveContainer # --------------------------------------------------------------------------- Describe 'Suspend-PveContainer' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Suspend-PveContainer' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Suspend-PveContainer' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Suspend-PveContainer' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Suspend-PveContainer' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Suspend-PveContainer' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Suspend-PveContainer' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'VmId should be Mandatory' { - Skip-IfMissing 'Suspend-PveContainer' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Suspend-PveContainer' { Suspend-PveContainer -Node 'pve' -VmId 100 -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -80,45 +36,16 @@ Describe 'Suspend-PveContainer' -Tag 'Unit' { # Resume-PveContainer # --------------------------------------------------------------------------- Describe 'Resume-PveContainer' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Resume-PveContainer' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Resume-PveContainer' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Resume-PveContainer' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Resume-PveContainer' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Resume-PveContainer' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Resume-PveContainer' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'VmId should be Mandatory' { - Skip-IfMissing 'Resume-PveContainer' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Resume-PveContainer' { Resume-PveContainer -Node 'pve' -VmId 100 -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -129,57 +56,16 @@ Describe 'Resume-PveContainer' -Tag 'Unit' { # Resize-PveContainerDisk # --------------------------------------------------------------------------- Describe 'Resize-PveContainerDisk' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Resize-PveContainerDisk' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Resize-PveContainerDisk' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Resize-PveContainerDisk' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Resize-PveContainerDisk' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Resize-PveContainerDisk' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Resize-PveContainerDisk' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'VmId should be Mandatory' { - Skip-IfMissing 'Resize-PveContainerDisk' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Disk should be Mandatory' { - Skip-IfMissing 'Resize-PveContainerDisk' - $isMandatory = $script:Cmd.Parameters['Disk'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Size should be Mandatory' { - Skip-IfMissing 'Resize-PveContainerDisk' - $isMandatory = $script:Cmd.Parameters['Size'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Resize-PveContainerDisk' { Resize-PveContainerDisk -Node 'pve' -VmId 100 -Disk 'rootfs' -Size '+5G' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -190,23 +76,13 @@ Describe 'Resize-PveContainerDisk' -Tag 'Unit' { # New-PveContainerTemplate # --------------------------------------------------------------------------- Describe 'New-PveContainerTemplate' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'New-PveContainerTemplate' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PveContainerTemplate' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'New-PveContainerTemplate' } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { - Skip-IfMissing 'New-PveContainerTemplate' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High' { - Skip-IfMissing 'New-PveContainerTemplate' $attr = $script:Cmd.ImplementingType.GetCustomAttributes( [System.Management.Automation.CmdletAttribute], $false) | Select-Object -First 1 @@ -214,24 +90,8 @@ Describe 'New-PveContainerTemplate' -Tag 'Unit' { } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'New-PveContainerTemplate' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'VmId should be Mandatory' { - Skip-IfMissing 'New-PveContainerTemplate' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'New-PveContainerTemplate' { New-PveContainerTemplate -Node 'pve' -VmId 100 -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -242,57 +102,16 @@ Describe 'New-PveContainerTemplate' -Tag 'Unit' { # Move-PveContainerVolume # --------------------------------------------------------------------------- Describe 'Move-PveContainerVolume' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Move-PveContainerVolume' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Move-PveContainerVolume' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Move-PveContainerVolume' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Move-PveContainerVolume' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Move-PveContainerVolume' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Move-PveContainerVolume' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'VmId should be Mandatory' { - Skip-IfMissing 'Move-PveContainerVolume' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Volume should be Mandatory' { - Skip-IfMissing 'Move-PveContainerVolume' - $isMandatory = $script:Cmd.Parameters['Volume'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Storage should be Mandatory' { - Skip-IfMissing 'Move-PveContainerVolume' - $isMandatory = $script:Cmd.Parameters['Storage'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Move-PveContainerVolume' { Move-PveContainerVolume -Node 'pve' -VmId 100 -Volume 'rootfs' -Storage 'local-lvm' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -303,38 +122,10 @@ Describe 'Move-PveContainerVolume' -Tag 'Unit' { # Get-PveContainerInterface # --------------------------------------------------------------------------- Describe 'Get-PveContainerInterface' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveContainerInterface' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveContainerInterface' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveContainerInterface' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Get-PveContainerInterface' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'VmId should be Mandatory' { - Skip-IfMissing 'Get-PveContainerInterface' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveContainerInterface' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveContainerInterface' { Get-PveContainerInterface -Node 'pve' -VmId 100 -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } diff --git a/tests/PSProxmoxVE.Tests/Containers/ContainerLifecycle.Tests.ps1 b/tests/PSProxmoxVE.Tests/Containers/ContainerLifecycle.Tests.ps1 index 80f9b25..20c1214 100644 --- a/tests/PSProxmoxVE.Tests/Containers/ContainerLifecycle.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Containers/ContainerLifecycle.Tests.ps1 @@ -6,75 +6,28 @@ Start-PveContainer, Stop-PveContainer, Restart-PveContainer. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled into the DLL the test is marked Skipped. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 # Pre-calculate availability for each cmdlet. - $script:Availability = @{} - foreach ($name in @('New-PveContainer', 'Remove-PveContainer', - 'Start-PveContainer', 'Stop-PveContainer', - 'Restart-PveContainer', - 'Get-PveContainerConfig', 'Set-PveContainerConfig', - 'Copy-PveContainer', 'Move-PveContainer')) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } } # --------------------------------------------------------------------------- # New-PveContainer # --------------------------------------------------------------------------- Describe 'New-PveContainer' { - - BeforeAll { $script:Cmd = Get-Command 'New-PveContainer' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PveContainer' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'New-PveContainer' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'New-PveContainer' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'New-PveContainer' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - } - - Context 'Optional parameters' { - It 'Should have Wait switch parameter' { - Skip-IfMissing 'New-PveContainer' - $script:Cmd.Parameters.ContainsKey('Wait') | Should -BeTrue - } - - It 'Should have Session parameter' { - Skip-IfMissing 'New-PveContainer' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } - Context 'Without active session' { It 'Should throw when no session is active (without -WhatIf)' { - Skip-IfMissing 'New-PveContainer' { New-PveContainer -Node 'pve-node1' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -85,24 +38,14 @@ Describe 'New-PveContainer' { # Remove-PveContainer # --------------------------------------------------------------------------- Describe 'Remove-PveContainer' { - - BeforeAll { $script:Cmd = Get-Command 'Remove-PveContainer' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Remove-PveContainer' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Remove-PveContainer' } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { - Skip-IfMissing 'Remove-PveContainer' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High' { - Skip-IfMissing 'Remove-PveContainer' $attr = $script:Cmd.ImplementingType.GetCustomAttributes( [System.Management.Automation.CmdletAttribute], $false) | Select-Object -First 1 @@ -110,42 +53,12 @@ Describe 'Remove-PveContainer' { } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Remove-PveContainer' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'VmId should be Mandatory' { - Skip-IfMissing 'Remove-PveContainer' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - - Context 'Optional parameters' { - It 'Should have Purge switch parameter' { - Skip-IfMissing 'Remove-PveContainer' - $script:Cmd.Parameters.ContainsKey('Purge') | Should -BeTrue - } - - It 'Should have Wait switch parameter' { - Skip-IfMissing 'Remove-PveContainer' - $script:Cmd.Parameters.ContainsKey('Wait') | Should -BeTrue - } - } - Context 'Without active session' { It 'Should throw when no session is active (without -WhatIf)' { - Skip-IfMissing 'Remove-PveContainer' { Remove-PveContainer -Node 'pve-node1' -VmId 200 -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } It 'Should not throw with -WhatIf' { - Skip-IfMissing 'Remove-PveContainer' { Remove-PveContainer -Node 'pve-node1' -VmId 200 -WhatIf -ErrorAction Stop } | Should -Not -Throw } @@ -156,45 +69,16 @@ Describe 'Remove-PveContainer' { # Start-PveContainer # --------------------------------------------------------------------------- Describe 'Start-PveContainer' { - - BeforeAll { $script:Cmd = Get-Command 'Start-PveContainer' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Start-PveContainer' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Start-PveContainer' } Context 'Parameter metadata' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Start-PveContainer' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'VmId should be Mandatory' { - Skip-IfMissing 'Start-PveContainer' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Should have Wait switch parameter' { - Skip-IfMissing 'Start-PveContainer' - $script:Cmd.Parameters.ContainsKey('Wait') | Should -BeTrue - } - It 'Should support ShouldProcess' { - Skip-IfMissing 'Start-PveContainer' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Start-PveContainer' { Start-PveContainer -Node 'pve-node1' -VmId 200 -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -205,45 +89,16 @@ Describe 'Start-PveContainer' { # Stop-PveContainer # --------------------------------------------------------------------------- Describe 'Stop-PveContainer' { - - BeforeAll { $script:Cmd = Get-Command 'Stop-PveContainer' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Stop-PveContainer' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Stop-PveContainer' } Context 'Parameter metadata' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Stop-PveContainer' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'VmId should be Mandatory' { - Skip-IfMissing 'Stop-PveContainer' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Should have Wait switch parameter' { - Skip-IfMissing 'Stop-PveContainer' - $script:Cmd.Parameters.ContainsKey('Wait') | Should -BeTrue - } - It 'Should support ShouldProcess' { - Skip-IfMissing 'Stop-PveContainer' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Stop-PveContainer' { Stop-PveContainer -Node 'pve-node1' -VmId 200 -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -254,40 +109,16 @@ Describe 'Stop-PveContainer' { # Restart-PveContainer # --------------------------------------------------------------------------- Describe 'Restart-PveContainer' { - - BeforeAll { $script:Cmd = Get-Command 'Restart-PveContainer' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Restart-PveContainer' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Restart-PveContainer' } Context 'Parameter metadata' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Restart-PveContainer' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'VmId should be Mandatory' { - Skip-IfMissing 'Restart-PveContainer' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Should support ShouldProcess' { - Skip-IfMissing 'Restart-PveContainer' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Restart-PveContainer' { Restart-PveContainer -Node 'pve-node1' -VmId 200 -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -298,57 +129,16 @@ Describe 'Restart-PveContainer' { # Move-PveContainer # --------------------------------------------------------------------------- Describe 'Move-PveContainer' { - - BeforeAll { $script:Cmd = Get-Command 'Move-PveContainer' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Move-PveContainer' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Move-PveContainer' } Context 'Parameter metadata' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Move-PveContainer' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'VmId should be Mandatory' { - Skip-IfMissing 'Move-PveContainer' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'TargetNode should be Mandatory' { - Skip-IfMissing 'Move-PveContainer' - $isMandatory = $script:Cmd.Parameters['TargetNode'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Should have Online switch parameter' { - Skip-IfMissing 'Move-PveContainer' - $script:Cmd.Parameters.ContainsKey('Online') | Should -BeTrue - } - - It 'Should have Wait switch parameter' { - Skip-IfMissing 'Move-PveContainer' - $script:Cmd.Parameters.ContainsKey('Wait') | Should -BeTrue - } - It 'Should support ShouldProcess' { - Skip-IfMissing 'Move-PveContainer' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Move-PveContainer' { Move-PveContainer -Node 'pve-node1' -VmId 200 -TargetNode 'pve-node2' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } diff --git a/tests/PSProxmoxVE.Tests/Containers/ContainerSnapshotCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Containers/ContainerSnapshotCmdlets.Tests.ps1 index c3e747b..44b2d35 100644 --- a/tests/PSProxmoxVE.Tests/Containers/ContainerSnapshotCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Containers/ContainerSnapshotCmdlets.Tests.ps1 @@ -6,93 +6,20 @@ Remove-PveContainerSnapshot, Restore-PveContainerSnapshot. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:Availability = @{} - foreach ($name in @('Get-PveContainerSnapshot', 'New-PveContainerSnapshot', - 'Remove-PveContainerSnapshot', 'Restore-PveContainerSnapshot')) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } -} - -# --------------------------------------------------------------------------- -# Manifest contract -# --------------------------------------------------------------------------- -Describe 'Container snapshot cmdlets — manifest declarations' { - BeforeAll { - $manifestPath = Join-Path (Get-Module PSProxmoxVE).ModuleBase 'PSProxmoxVE.psd1' - $script:Manifest = if (Test-Path $manifestPath) { Import-PowerShellDataFile $manifestPath } else { $null } - } - - It " should be declared in CmdletsToExport" -TestCases @( - @{ cmdName = 'Get-PveContainerSnapshot' } - @{ cmdName = 'New-PveContainerSnapshot' } - @{ cmdName = 'Remove-PveContainerSnapshot' } - @{ cmdName = 'Restore-PveContainerSnapshot' } - ) { - if ($null -eq $script:Manifest) { Set-ItResult -Skipped -Because 'Manifest not found'; return } - $script:Manifest.CmdletsToExport | Should -Contain $cmdName - } } # --------------------------------------------------------------------------- # Get-PveContainerSnapshot # --------------------------------------------------------------------------- Describe 'Get-PveContainerSnapshot' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveContainerSnapshot' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveContainerSnapshot' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveContainerSnapshot' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Parameter metadata' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Get-PveContainerSnapshot' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'VmId should be Mandatory' { - Skip-IfMissing 'Get-PveContainerSnapshot' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Should have Name parameter (optional filter by snapshot name)' { - Skip-IfMissing 'Get-PveContainerSnapshot' - $script:Cmd.Parameters.ContainsKey('Name') | Should -BeTrue - } - - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveContainerSnapshot' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveContainerSnapshot' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveContainerSnapshot' { Get-PveContainerSnapshot -Node 'pve-node1' -VmId 100 -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -103,66 +30,22 @@ Describe 'Get-PveContainerSnapshot' { # New-PveContainerSnapshot # --------------------------------------------------------------------------- Describe 'New-PveContainerSnapshot' { + BeforeAll { $script:Cmd = Get-Command 'New-PveContainerSnapshot' } - BeforeAll { $script:Cmd = Get-Command 'New-PveContainerSnapshot' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PveContainerSnapshot' - $script:Cmd | Should -Not -BeNullOrEmpty + Context 'Parameter surface' { + It 'Should NOT have IncludeVmState (LXC containers do not support RAM snapshots)' { + $script:Cmd.Parameters.ContainsKey('IncludeVmState') | Should -BeFalse } } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'New-PveContainerSnapshot' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'New-PveContainerSnapshot' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'VmId should be Mandatory' { - Skip-IfMissing 'New-PveContainerSnapshot' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Name (snapshot name) should be Mandatory' { - Skip-IfMissing 'New-PveContainerSnapshot' - $isMandatory = $script:Cmd.Parameters['Name'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - - Context 'Optional parameters' { - It 'Should have Description parameter' { - Skip-IfMissing 'New-PveContainerSnapshot' - $script:Cmd.Parameters.ContainsKey('Description') | Should -BeTrue - } - - It 'Should have Wait switch parameter' { - Skip-IfMissing 'New-PveContainerSnapshot' - $script:Cmd.Parameters.ContainsKey('Wait') | Should -BeTrue - } - - It 'Should NOT have IncludeVmState (LXC containers do not support RAM snapshots)' { - Skip-IfMissing 'New-PveContainerSnapshot' - $script:Cmd.Parameters.ContainsKey('IncludeVmState') | Should -BeFalse - } - } - Context 'Without active session' { It 'Should throw when no session is active (without -WhatIf)' { - Skip-IfMissing 'New-PveContainerSnapshot' { New-PveContainerSnapshot -Node 'pve-node1' -VmId 100 -Name 'snap1' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -173,24 +56,14 @@ Describe 'New-PveContainerSnapshot' { # Remove-PveContainerSnapshot # --------------------------------------------------------------------------- Describe 'Remove-PveContainerSnapshot' { - - BeforeAll { $script:Cmd = Get-Command 'Remove-PveContainerSnapshot' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Remove-PveContainerSnapshot' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Remove-PveContainerSnapshot' } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { - Skip-IfMissing 'Remove-PveContainerSnapshot' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High' { - Skip-IfMissing 'Remove-PveContainerSnapshot' $attr = $script:Cmd.ImplementingType.GetCustomAttributes( [System.Management.Automation.CmdletAttribute], $false) | Select-Object -First 1 @@ -198,32 +71,8 @@ Describe 'Remove-PveContainerSnapshot' { } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Remove-PveContainerSnapshot' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'VmId should be Mandatory' { - Skip-IfMissing 'Remove-PveContainerSnapshot' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Name should be Mandatory' { - Skip-IfMissing 'Remove-PveContainerSnapshot' - $isMandatory = $script:Cmd.Parameters['Name'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active (without -WhatIf)' { - Skip-IfMissing 'Remove-PveContainerSnapshot' { Remove-PveContainerSnapshot -Node 'pve-node1' -VmId 100 -Name 'snap1' -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -234,24 +83,14 @@ Describe 'Remove-PveContainerSnapshot' { # Restore-PveContainerSnapshot # --------------------------------------------------------------------------- Describe 'Restore-PveContainerSnapshot' { - - BeforeAll { $script:Cmd = Get-Command 'Restore-PveContainerSnapshot' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Restore-PveContainerSnapshot' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Restore-PveContainerSnapshot' } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { - Skip-IfMissing 'Restore-PveContainerSnapshot' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High' { - Skip-IfMissing 'Restore-PveContainerSnapshot' $attr = $script:Cmd.ImplementingType.GetCustomAttributes( [System.Management.Automation.CmdletAttribute], $false) | Select-Object -First 1 @@ -259,39 +98,8 @@ Describe 'Restore-PveContainerSnapshot' { } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Restore-PveContainerSnapshot' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'VmId should be Mandatory' { - Skip-IfMissing 'Restore-PveContainerSnapshot' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Name should be Mandatory' { - Skip-IfMissing 'Restore-PveContainerSnapshot' - $isMandatory = $script:Cmd.Parameters['Name'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - - Context 'Optional parameters' { - It 'Should have Wait switch parameter' { - Skip-IfMissing 'Restore-PveContainerSnapshot' - $script:Cmd.Parameters.ContainsKey('Wait') | Should -BeTrue - } - } - Context 'Without active session' { It 'Should throw when no session is active (without -WhatIf)' { - Skip-IfMissing 'Restore-PveContainerSnapshot' { Restore-PveContainerSnapshot -Node 'pve-node1' -VmId 100 -Name 'snap1' -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } diff --git a/tests/PSProxmoxVE.Tests/Containers/Get-PveContainer.Tests.ps1 b/tests/PSProxmoxVE.Tests/Containers/Get-PveContainer.Tests.ps1 index 7a8c1f4..16c20f1 100644 --- a/tests/PSProxmoxVE.Tests/Containers/Get-PveContainer.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Containers/Get-PveContainer.Tests.ps1 @@ -5,79 +5,19 @@ All tests are fully offline — no live Proxmox VE target is required. Get-PveContainer mirrors the design of Get-PveVm for LXC containers. - If the cmdlet is not yet implemented (dll compiled without it), tests - that depend on invocation are marked Skipped rather than Failed. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:CmdExists = $null -ne (Get-Command 'Get-PveContainer' -ErrorAction SilentlyContinue) } Describe 'Get-PveContainer' { - - Context 'Command existence' { - It 'Get-PveContainer should be listed in the module manifest CmdletsToExport' { - # The .psd1 declares the cmdlet; implementation may be pending. - $manifestPath = Join-Path (Get-Module PSProxmoxVE).ModuleBase 'PSProxmoxVE.psd1' - if (Test-Path $manifestPath) { - $manifest = Import-PowerShellDataFile $manifestPath - $manifest.CmdletsToExport | Should -Contain 'Get-PveContainer' - } - else { - Set-ItResult -Skipped -Because 'Module manifest not found at expected path' - } - } - - It 'Should be available after module import (or skip if not yet compiled)' { - if (-not $script:CmdExists) { - Set-ItResult -Skipped -Because 'Get-PveContainer is not yet implemented in this build' - return - } - (Get-Command 'Get-PveContainer').CommandType | Should -Be 'Cmdlet' - } - } - Context 'Parameter metadata' { BeforeAll { - $script:Cmd = Get-Command 'Get-PveContainer' -ErrorAction SilentlyContinue - } - - It 'Should have Node parameter' { - if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return } - $script:Cmd.Parameters.ContainsKey('Node') | Should -BeTrue - } - - It 'Node should not be Mandatory (all-nodes query when omitted)' { - if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return } - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } - - It 'Should have VmId parameter' { - if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return } - $script:Cmd.Parameters.ContainsKey('VmId') | Should -BeTrue - } - - It 'Should have Name parameter' { - if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return } - $script:Cmd.Parameters.ContainsKey('Name') | Should -BeTrue - } - - It 'Should have Status parameter' { - if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return } - $script:Cmd.Parameters.ContainsKey('Status') | Should -BeTrue - } - - It 'Should have Session parameter (inherited from PveCmdletBase)' { - if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return } - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue + $script:Cmd = Get-Command 'Get-PveContainer' } It 'Node should accept pipeline input by property name' { - if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return } $node = $script:Cmd.Parameters['Node'] $acceptsByPropName = $node.ParameterSets.Values | Where-Object { $_.ValueFromPipelineByPropertyName } @@ -87,7 +27,6 @@ Describe 'Get-PveContainer' { Context 'Without active session' { It 'Should throw when no session is active' { - if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return } { Get-PveContainer -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } diff --git a/tests/PSProxmoxVE.Tests/Containers/New-PveContainer.Tests.ps1 b/tests/PSProxmoxVE.Tests/Containers/New-PveContainer.Tests.ps1 index 8b989f8..723813f 100644 --- a/tests/PSProxmoxVE.Tests/Containers/New-PveContainer.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Containers/New-PveContainer.Tests.ps1 @@ -10,18 +10,6 @@ BeforeAll { } Describe 'New-PveContainer' { - - Context 'Command existence' { - It 'Should be available after module import' { - Get-Command 'New-PveContainer' -ErrorAction SilentlyContinue | - Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - (Get-Command 'New-PveContainer').CommandType | Should -Be 'Cmdlet' - } - } - Context 'ShouldProcess support' { BeforeAll { $script:Cmd = Get-Command 'New-PveContainer' diff --git a/tests/PSProxmoxVE.Tests/Firewall/FirewallAliasCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Firewall/FirewallAliasCmdlets.Tests.ps1 index cc455ba..64fd125 100644 --- a/tests/PSProxmoxVE.Tests/Firewall/FirewallAliasCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Firewall/FirewallAliasCmdlets.Tests.ps1 @@ -5,78 +5,20 @@ Get-PveFirewallAlias, New-PveFirewallAlias, Set-PveFirewallAlias, Remove-PveFirewallAlias. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:Availability = @{} - foreach ($name in @('Get-PveFirewallAlias', 'New-PveFirewallAlias', 'Set-PveFirewallAlias', 'Remove-PveFirewallAlias')) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } -} - -# --------------------------------------------------------------------------- -# Manifest contract -# --------------------------------------------------------------------------- -Describe 'Firewall alias cmdlets — manifest declarations' { - BeforeAll { - $manifestPath = Join-Path (Get-Module PSProxmoxVE).ModuleBase 'PSProxmoxVE.psd1' - $script:Manifest = if (Test-Path $manifestPath) { Import-PowerShellDataFile $manifestPath } else { $null } - } - - It " should be declared in CmdletsToExport" -TestCases @( - @{ cmdName = 'Get-PveFirewallAlias' } - @{ cmdName = 'New-PveFirewallAlias' } - @{ cmdName = 'Set-PveFirewallAlias' } - @{ cmdName = 'Remove-PveFirewallAlias' } - ) { - if ($null -eq $script:Manifest) { Set-ItResult -Skipped -Because 'Manifest not found'; return } - $script:Manifest.CmdletsToExport | Should -Contain $cmdName - } } # --------------------------------------------------------------------------- # Get-PveFirewallAlias # --------------------------------------------------------------------------- Describe 'Get-PveFirewallAlias' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveFirewallAlias' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveFirewallAlias' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveFirewallAlias' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Parameter metadata' { - It 'Should have optional Name parameter' { - Skip-IfMissing 'Get-PveFirewallAlias' - $script:Cmd.Parameters.ContainsKey('Name') | Should -BeTrue - } - - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveFirewallAlias' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveFirewallAlias' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveFirewallAlias' { Get-PveFirewallAlias -Level Cluster -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -87,49 +29,16 @@ Describe 'Get-PveFirewallAlias' { # New-PveFirewallAlias # --------------------------------------------------------------------------- Describe 'New-PveFirewallAlias' { - - BeforeAll { $script:Cmd = Get-Command 'New-PveFirewallAlias' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PveFirewallAlias' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'New-PveFirewallAlias' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'New-PveFirewallAlias' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Name should be Mandatory' { - Skip-IfMissing 'New-PveFirewallAlias' - $isMandatory = $script:Cmd.Parameters['Name'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Cidr should be Mandatory' { - Skip-IfMissing 'New-PveFirewallAlias' - $isMandatory = $script:Cmd.Parameters['Cidr'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - - Context 'Optional parameters' { - It 'Should have Comment parameter' { - Skip-IfMissing 'New-PveFirewallAlias' - $script:Cmd.Parameters.ContainsKey('Comment') | Should -BeTrue - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'New-PveFirewallAlias' { New-PveFirewallAlias -Name 'testalias' -Cidr '10.0.0.0/24' -Level Cluster -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -140,40 +49,16 @@ Describe 'New-PveFirewallAlias' { # Set-PveFirewallAlias # --------------------------------------------------------------------------- Describe 'Set-PveFirewallAlias' { - - BeforeAll { $script:Cmd = Get-Command 'Set-PveFirewallAlias' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Set-PveFirewallAlias' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Set-PveFirewallAlias' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Set-PveFirewallAlias' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Name should be Mandatory' { - Skip-IfMissing 'Set-PveFirewallAlias' - $isMandatory = $script:Cmd.Parameters['Name'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Should have optional Cidr parameter' { - Skip-IfMissing 'Set-PveFirewallAlias' - $script:Cmd.Parameters.ContainsKey('Cidr') | Should -BeTrue - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Set-PveFirewallAlias' { Set-PveFirewallAlias -Name 'testalias' -Cidr '10.0.0.0/24' -Level Cluster -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -184,24 +69,14 @@ Describe 'Set-PveFirewallAlias' { # Remove-PveFirewallAlias # --------------------------------------------------------------------------- Describe 'Remove-PveFirewallAlias' { - - BeforeAll { $script:Cmd = Get-Command 'Remove-PveFirewallAlias' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Remove-PveFirewallAlias' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Remove-PveFirewallAlias' } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { - Skip-IfMissing 'Remove-PveFirewallAlias' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High' { - Skip-IfMissing 'Remove-PveFirewallAlias' $attr = $script:Cmd.ImplementingType.GetCustomAttributes( [System.Management.Automation.CmdletAttribute], $false) | Select-Object -First 1 @@ -209,18 +84,8 @@ Describe 'Remove-PveFirewallAlias' { } } - Context 'Required parameters' { - It 'Name should be Mandatory' { - Skip-IfMissing 'Remove-PveFirewallAlias' - $isMandatory = $script:Cmd.Parameters['Name'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Remove-PveFirewallAlias' { Remove-PveFirewallAlias -Name 'testalias' -Confirm:$false -Level Cluster -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } diff --git a/tests/PSProxmoxVE.Tests/Firewall/FirewallGroupCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Firewall/FirewallGroupCmdlets.Tests.ps1 index f5c2bc3..18027d9 100644 --- a/tests/PSProxmoxVE.Tests/Firewall/FirewallGroupCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Firewall/FirewallGroupCmdlets.Tests.ps1 @@ -5,77 +5,20 @@ Get-PveFirewallGroup, New-PveFirewallGroup, Remove-PveFirewallGroup. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:Availability = @{} - foreach ($name in @('Get-PveFirewallGroup', 'New-PveFirewallGroup', 'Remove-PveFirewallGroup')) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } -} - -# --------------------------------------------------------------------------- -# Manifest contract -# --------------------------------------------------------------------------- -Describe 'Firewall group cmdlets — manifest declarations' { - BeforeAll { - $manifestPath = Join-Path (Get-Module PSProxmoxVE).ModuleBase 'PSProxmoxVE.psd1' - $script:Manifest = if (Test-Path $manifestPath) { Import-PowerShellDataFile $manifestPath } else { $null } - } - - It " should be declared in CmdletsToExport" -TestCases @( - @{ cmdName = 'Get-PveFirewallGroup' } - @{ cmdName = 'New-PveFirewallGroup' } - @{ cmdName = 'Remove-PveFirewallGroup' } - ) { - if ($null -eq $script:Manifest) { Set-ItResult -Skipped -Because 'Manifest not found'; return } - $script:Manifest.CmdletsToExport | Should -Contain $cmdName - } } # --------------------------------------------------------------------------- # Get-PveFirewallGroup # --------------------------------------------------------------------------- Describe 'Get-PveFirewallGroup' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveFirewallGroup' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveFirewallGroup' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveFirewallGroup' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Parameter metadata' { - It 'Should have optional Group parameter' { - Skip-IfMissing 'Get-PveFirewallGroup' - $script:Cmd.Parameters.ContainsKey('Group') | Should -BeTrue - } - - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveFirewallGroup' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveFirewallGroup' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveFirewallGroup' { Get-PveFirewallGroup -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -86,42 +29,16 @@ Describe 'Get-PveFirewallGroup' { # New-PveFirewallGroup # --------------------------------------------------------------------------- Describe 'New-PveFirewallGroup' { - - BeforeAll { $script:Cmd = Get-Command 'New-PveFirewallGroup' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PveFirewallGroup' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'New-PveFirewallGroup' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'New-PveFirewallGroup' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Group should be Mandatory' { - Skip-IfMissing 'New-PveFirewallGroup' - $isMandatory = $script:Cmd.Parameters['Group'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - - Context 'Optional parameters' { - It 'Should have Comment parameter' { - Skip-IfMissing 'New-PveFirewallGroup' - $script:Cmd.Parameters.ContainsKey('Comment') | Should -BeTrue - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'New-PveFirewallGroup' { New-PveFirewallGroup -Group 'testgroup' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -132,24 +49,14 @@ Describe 'New-PveFirewallGroup' { # Remove-PveFirewallGroup # --------------------------------------------------------------------------- Describe 'Remove-PveFirewallGroup' { - - BeforeAll { $script:Cmd = Get-Command 'Remove-PveFirewallGroup' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Remove-PveFirewallGroup' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Remove-PveFirewallGroup' } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { - Skip-IfMissing 'Remove-PveFirewallGroup' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High' { - Skip-IfMissing 'Remove-PveFirewallGroup' $attr = $script:Cmd.ImplementingType.GetCustomAttributes( [System.Management.Automation.CmdletAttribute], $false) | Select-Object -First 1 @@ -157,18 +64,8 @@ Describe 'Remove-PveFirewallGroup' { } } - Context 'Required parameters' { - It 'Group should be Mandatory' { - Skip-IfMissing 'Remove-PveFirewallGroup' - $isMandatory = $script:Cmd.Parameters['Group'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Remove-PveFirewallGroup' { Remove-PveFirewallGroup -Group 'testgroup' -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } diff --git a/tests/PSProxmoxVE.Tests/Firewall/FirewallIpSetCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Firewall/FirewallIpSetCmdlets.Tests.ps1 index 0705eac..62afec0 100644 --- a/tests/PSProxmoxVE.Tests/Firewall/FirewallIpSetCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Firewall/FirewallIpSetCmdlets.Tests.ps1 @@ -7,85 +7,20 @@ Remove-PveFirewallIpSetEntry. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:Availability = @{} - foreach ($name in @( - 'Get-PveFirewallIpSet', 'New-PveFirewallIpSet', 'Remove-PveFirewallIpSet', - 'Get-PveFirewallIpSetEntry', 'New-PveFirewallIpSetEntry', 'Set-PveFirewallIpSetEntry', - 'Remove-PveFirewallIpSetEntry' - )) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } -} - -# --------------------------------------------------------------------------- -# Manifest contract -# --------------------------------------------------------------------------- -Describe 'Firewall IP set cmdlets — manifest declarations' { - BeforeAll { - $manifestPath = Join-Path (Get-Module PSProxmoxVE).ModuleBase 'PSProxmoxVE.psd1' - $script:Manifest = if (Test-Path $manifestPath) { Import-PowerShellDataFile $manifestPath } else { $null } - } - - It " should be declared in CmdletsToExport" -TestCases @( - @{ cmdName = 'Get-PveFirewallIpSet' } - @{ cmdName = 'New-PveFirewallIpSet' } - @{ cmdName = 'Remove-PveFirewallIpSet' } - @{ cmdName = 'Get-PveFirewallIpSetEntry' } - @{ cmdName = 'New-PveFirewallIpSetEntry' } - @{ cmdName = 'Set-PveFirewallIpSetEntry' } - @{ cmdName = 'Remove-PveFirewallIpSetEntry' } - ) { - if ($null -eq $script:Manifest) { Set-ItResult -Skipped -Because 'Manifest not found'; return } - $script:Manifest.CmdletsToExport | Should -Contain $cmdName - } } # --------------------------------------------------------------------------- # Get-PveFirewallIpSet # --------------------------------------------------------------------------- Describe 'Get-PveFirewallIpSet' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveFirewallIpSet' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveFirewallIpSet' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveFirewallIpSet' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Parameter metadata' { - It 'Should have optional Name parameter' { - Skip-IfMissing 'Get-PveFirewallIpSet' - $script:Cmd.Parameters.ContainsKey('Name') | Should -BeTrue - } - - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveFirewallIpSet' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveFirewallIpSet' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveFirewallIpSet' { Get-PveFirewallIpSet -Level Cluster -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -96,42 +31,16 @@ Describe 'Get-PveFirewallIpSet' { # New-PveFirewallIpSet # --------------------------------------------------------------------------- Describe 'New-PveFirewallIpSet' { - - BeforeAll { $script:Cmd = Get-Command 'New-PveFirewallIpSet' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PveFirewallIpSet' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'New-PveFirewallIpSet' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'New-PveFirewallIpSet' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Name should be Mandatory' { - Skip-IfMissing 'New-PveFirewallIpSet' - $isMandatory = $script:Cmd.Parameters['Name'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - - Context 'Optional parameters' { - It 'Should have Comment parameter' { - Skip-IfMissing 'New-PveFirewallIpSet' - $script:Cmd.Parameters.ContainsKey('Comment') | Should -BeTrue - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'New-PveFirewallIpSet' { New-PveFirewallIpSet -Name 'testipset' -Level Cluster -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -142,24 +51,14 @@ Describe 'New-PveFirewallIpSet' { # Remove-PveFirewallIpSet # --------------------------------------------------------------------------- Describe 'Remove-PveFirewallIpSet' { - - BeforeAll { $script:Cmd = Get-Command 'Remove-PveFirewallIpSet' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Remove-PveFirewallIpSet' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Remove-PveFirewallIpSet' } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { - Skip-IfMissing 'Remove-PveFirewallIpSet' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High' { - Skip-IfMissing 'Remove-PveFirewallIpSet' $attr = $script:Cmd.ImplementingType.GetCustomAttributes( [System.Management.Automation.CmdletAttribute], $false) | Select-Object -First 1 @@ -167,18 +66,8 @@ Describe 'Remove-PveFirewallIpSet' { } } - Context 'Required parameters' { - It 'Name should be Mandatory' { - Skip-IfMissing 'Remove-PveFirewallIpSet' - $isMandatory = $script:Cmd.Parameters['Name'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Remove-PveFirewallIpSet' { Remove-PveFirewallIpSet -Name 'testipset' -Confirm:$false -Level Cluster -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -189,40 +78,10 @@ Describe 'Remove-PveFirewallIpSet' { # Get-PveFirewallIpSetEntry # --------------------------------------------------------------------------- Describe 'Get-PveFirewallIpSetEntry' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveFirewallIpSetEntry' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveFirewallIpSetEntry' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveFirewallIpSetEntry' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Required parameters' { - It 'Name should be Mandatory' { - Skip-IfMissing 'Get-PveFirewallIpSetEntry' - $isMandatory = $script:Cmd.Parameters['Name'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - - Context 'Parameter metadata' { - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveFirewallIpSetEntry' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveFirewallIpSetEntry' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveFirewallIpSetEntry' { Get-PveFirewallIpSetEntry -Name 'testipset' -Level Cluster -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -233,42 +92,16 @@ Describe 'Get-PveFirewallIpSetEntry' { # New-PveFirewallIpSetEntry # --------------------------------------------------------------------------- Describe 'New-PveFirewallIpSetEntry' { - - BeforeAll { $script:Cmd = Get-Command 'New-PveFirewallIpSetEntry' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PveFirewallIpSetEntry' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'New-PveFirewallIpSetEntry' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'New-PveFirewallIpSetEntry' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Name should be Mandatory' { - Skip-IfMissing 'New-PveFirewallIpSetEntry' - $isMandatory = $script:Cmd.Parameters['Name'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Cidr should be Mandatory' { - Skip-IfMissing 'New-PveFirewallIpSetEntry' - $isMandatory = $script:Cmd.Parameters['Cidr'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'New-PveFirewallIpSetEntry' { New-PveFirewallIpSetEntry -Name 'testipset' -Cidr '10.0.0.1' -Level Cluster -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -279,42 +112,16 @@ Describe 'New-PveFirewallIpSetEntry' { # Set-PveFirewallIpSetEntry # --------------------------------------------------------------------------- Describe 'Set-PveFirewallIpSetEntry' { - - BeforeAll { $script:Cmd = Get-Command 'Set-PveFirewallIpSetEntry' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Set-PveFirewallIpSetEntry' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Set-PveFirewallIpSetEntry' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Set-PveFirewallIpSetEntry' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Name should be Mandatory' { - Skip-IfMissing 'Set-PveFirewallIpSetEntry' - $isMandatory = $script:Cmd.Parameters['Name'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Cidr should be Mandatory' { - Skip-IfMissing 'Set-PveFirewallIpSetEntry' - $isMandatory = $script:Cmd.Parameters['Cidr'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Set-PveFirewallIpSetEntry' { Set-PveFirewallIpSetEntry -Name 'testipset' -Cidr '10.0.0.1' -Level Cluster -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -325,24 +132,14 @@ Describe 'Set-PveFirewallIpSetEntry' { # Remove-PveFirewallIpSetEntry # --------------------------------------------------------------------------- Describe 'Remove-PveFirewallIpSetEntry' { - - BeforeAll { $script:Cmd = Get-Command 'Remove-PveFirewallIpSetEntry' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Remove-PveFirewallIpSetEntry' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Remove-PveFirewallIpSetEntry' } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { - Skip-IfMissing 'Remove-PveFirewallIpSetEntry' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High' { - Skip-IfMissing 'Remove-PveFirewallIpSetEntry' $attr = $script:Cmd.ImplementingType.GetCustomAttributes( [System.Management.Automation.CmdletAttribute], $false) | Select-Object -First 1 @@ -350,25 +147,8 @@ Describe 'Remove-PveFirewallIpSetEntry' { } } - Context 'Required parameters' { - It 'Name should be Mandatory' { - Skip-IfMissing 'Remove-PveFirewallIpSetEntry' - $isMandatory = $script:Cmd.Parameters['Name'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Cidr should be Mandatory' { - Skip-IfMissing 'Remove-PveFirewallIpSetEntry' - $isMandatory = $script:Cmd.Parameters['Cidr'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Remove-PveFirewallIpSetEntry' { Remove-PveFirewallIpSetEntry -Name 'testipset' -Cidr '10.0.0.1' -Confirm:$false -Level Cluster -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } diff --git a/tests/PSProxmoxVE.Tests/Firewall/FirewallOptionsCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Firewall/FirewallOptionsCmdlets.Tests.ps1 index 4a2c38b..bdf0884 100644 --- a/tests/PSProxmoxVE.Tests/Firewall/FirewallOptionsCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Firewall/FirewallOptionsCmdlets.Tests.ps1 @@ -5,65 +5,20 @@ Get-PveFirewallOptions, Set-PveFirewallOptions, Get-PveFirewallRef. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:Availability = @{} - foreach ($name in @('Get-PveFirewallOptions', 'Set-PveFirewallOptions', 'Get-PveFirewallRef')) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } -} - -# --------------------------------------------------------------------------- -# Manifest contract -# --------------------------------------------------------------------------- -Describe 'Firewall options/ref cmdlets — manifest declarations' { - BeforeAll { - $manifestPath = Join-Path (Get-Module PSProxmoxVE).ModuleBase 'PSProxmoxVE.psd1' - $script:Manifest = if (Test-Path $manifestPath) { Import-PowerShellDataFile $manifestPath } else { $null } - } - - It " should be declared in CmdletsToExport" -TestCases @( - @{ cmdName = 'Get-PveFirewallOptions' } - @{ cmdName = 'Set-PveFirewallOptions' } - @{ cmdName = 'Get-PveFirewallRef' } - ) { - if ($null -eq $script:Manifest) { Set-ItResult -Skipped -Because 'Manifest not found'; return } - $script:Manifest.CmdletsToExport | Should -Contain $cmdName - } } # --------------------------------------------------------------------------- # Get-PveFirewallOptions # --------------------------------------------------------------------------- Describe 'Get-PveFirewallOptions' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveFirewallOptions' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveFirewallOptions' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveFirewallOptions' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveFirewallOptions' } Context 'Parameter metadata' { It 'Should have mandatory Level parameter with ValidateSet' { - Skip-IfMissing 'Get-PveFirewallOptions' $param = $script:Cmd.Parameters['Level'] $param | Should -Not -BeNullOrEmpty $isMandatory = $param.ParameterSets.Values | Where-Object { $_.IsMandatory } @@ -71,16 +26,10 @@ Describe 'Get-PveFirewallOptions' { $validateSet = $param.Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } $validateSet | Should -Not -BeNullOrEmpty } - - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveFirewallOptions' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveFirewallOptions' { Get-PveFirewallOptions -Level 'cluster' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -91,26 +40,16 @@ Describe 'Get-PveFirewallOptions' { # Set-PveFirewallOptions # --------------------------------------------------------------------------- Describe 'Set-PveFirewallOptions' { - - BeforeAll { $script:Cmd = Get-Command 'Set-PveFirewallOptions' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Set-PveFirewallOptions' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Set-PveFirewallOptions' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Set-PveFirewallOptions' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } Context 'Parameter metadata' { It 'Should have mandatory Level parameter with ValidateSet' { - Skip-IfMissing 'Set-PveFirewallOptions' $param = $script:Cmd.Parameters['Level'] $param | Should -Not -BeNullOrEmpty $isMandatory = $param.ParameterSets.Values | Where-Object { $_.IsMandatory } @@ -118,16 +57,10 @@ Describe 'Set-PveFirewallOptions' { $validateSet = $param.Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } $validateSet | Should -Not -BeNullOrEmpty } - - It 'Should have Enable parameter' { - Skip-IfMissing 'Set-PveFirewallOptions' - $script:Cmd.Parameters.ContainsKey('Enable') | Should -BeTrue - } } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Set-PveFirewallOptions' { Set-PveFirewallOptions -Level 'cluster' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -138,36 +71,10 @@ Describe 'Set-PveFirewallOptions' { # Get-PveFirewallRef # --------------------------------------------------------------------------- Describe 'Get-PveFirewallRef' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveFirewallRef' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveFirewallRef' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveFirewallRef' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Parameter metadata' { - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveFirewallRef' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - - It 'Should have optional Type parameter' { - Skip-IfMissing 'Get-PveFirewallRef' - $script:Cmd.Parameters.ContainsKey('Type') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveFirewallRef' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveFirewallRef' { Get-PveFirewallRef -Level Cluster -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } diff --git a/tests/PSProxmoxVE.Tests/Firewall/FirewallRuleCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Firewall/FirewallRuleCmdlets.Tests.ps1 index dbe9450..4f9ad23 100644 --- a/tests/PSProxmoxVE.Tests/Firewall/FirewallRuleCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Firewall/FirewallRuleCmdlets.Tests.ps1 @@ -5,66 +5,20 @@ Get-PveFirewallRule, New-PveFirewallRule, Set-PveFirewallRule, Remove-PveFirewallRule. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:Availability = @{} - foreach ($name in @('Get-PveFirewallRule', 'New-PveFirewallRule', 'Set-PveFirewallRule', 'Remove-PveFirewallRule')) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } -} - -# --------------------------------------------------------------------------- -# Manifest contract -# --------------------------------------------------------------------------- -Describe 'Firewall rule cmdlets — manifest declarations' { - BeforeAll { - $manifestPath = Join-Path (Get-Module PSProxmoxVE).ModuleBase 'PSProxmoxVE.psd1' - $script:Manifest = if (Test-Path $manifestPath) { Import-PowerShellDataFile $manifestPath } else { $null } - } - - It " should be declared in CmdletsToExport" -TestCases @( - @{ cmdName = 'Get-PveFirewallRule' } - @{ cmdName = 'New-PveFirewallRule' } - @{ cmdName = 'Set-PveFirewallRule' } - @{ cmdName = 'Remove-PveFirewallRule' } - ) { - if ($null -eq $script:Manifest) { Set-ItResult -Skipped -Because 'Manifest not found'; return } - $script:Manifest.CmdletsToExport | Should -Contain $cmdName - } } # --------------------------------------------------------------------------- # Get-PveFirewallRule # --------------------------------------------------------------------------- Describe 'Get-PveFirewallRule' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveFirewallRule' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveFirewallRule' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveFirewallRule' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveFirewallRule' } Context 'Parameter metadata' { It 'Should have mandatory Level parameter with ValidateSet' { - Skip-IfMissing 'Get-PveFirewallRule' $param = $script:Cmd.Parameters['Level'] $param | Should -Not -BeNullOrEmpty $isMandatory = $param.ParameterSets.Values | Where-Object { $_.IsMandatory } @@ -72,16 +26,10 @@ Describe 'Get-PveFirewallRule' { $validateSet = $param.Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } $validateSet | Should -Not -BeNullOrEmpty } - - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveFirewallRule' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveFirewallRule' { Get-PveFirewallRule -Level 'cluster' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -89,14 +37,12 @@ Describe 'Get-PveFirewallRule' { Context 'Group level' { It 'Should include Group in the Level ValidateSet' { - Skip-IfMissing 'Get-PveFirewallRule' $param = $script:Cmd.Parameters['Level'] $validateSet = $param.Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } $validateSet.ValidValues | Should -Contain 'Group' } It 'Should throw when Level is Group and Group is not specified' { - Skip-IfMissing 'Get-PveFirewallRule' { Get-PveFirewallRule -Level 'Group' -ErrorAction Stop } | Should -Throw '*Group is required when Level is Group*' } @@ -107,26 +53,16 @@ Describe 'Get-PveFirewallRule' { # New-PveFirewallRule # --------------------------------------------------------------------------- Describe 'New-PveFirewallRule' { - - BeforeAll { $script:Cmd = Get-Command 'New-PveFirewallRule' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PveFirewallRule' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'New-PveFirewallRule' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'New-PveFirewallRule' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } Context 'Parameter metadata' { It 'Should have mandatory Level parameter with ValidateSet' { - Skip-IfMissing 'New-PveFirewallRule' $param = $script:Cmd.Parameters['Level'] $param | Should -Not -BeNullOrEmpty $isMandatory = $param.ParameterSets.Values | Where-Object { $_.IsMandatory } @@ -134,21 +70,10 @@ Describe 'New-PveFirewallRule' { $validateSet = $param.Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } $validateSet | Should -Not -BeNullOrEmpty } - - It 'Should have Action parameter' { - Skip-IfMissing 'New-PveFirewallRule' - $script:Cmd.Parameters.ContainsKey('Action') | Should -BeTrue - } - - It 'Should have Type parameter' { - Skip-IfMissing 'New-PveFirewallRule' - $script:Cmd.Parameters.ContainsKey('Type') | Should -BeTrue - } } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'New-PveFirewallRule' { New-PveFirewallRule -Level 'cluster' -Action 'ACCEPT' -Type 'in' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -156,14 +81,12 @@ Describe 'New-PveFirewallRule' { Context 'Group level' { It 'Should include Group in the Level ValidateSet' { - Skip-IfMissing 'New-PveFirewallRule' $param = $script:Cmd.Parameters['Level'] $validateSet = $param.Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } $validateSet.ValidValues | Should -Contain 'Group' } It 'Should throw when Level is Group and Group is not specified' { - Skip-IfMissing 'New-PveFirewallRule' { New-PveFirewallRule -Level 'Group' -Action 'ACCEPT' -Type 'in' -ErrorAction Stop } | Should -Throw '*Group is required when Level is Group*' } @@ -174,26 +97,16 @@ Describe 'New-PveFirewallRule' { # Set-PveFirewallRule # --------------------------------------------------------------------------- Describe 'Set-PveFirewallRule' { - - BeforeAll { $script:Cmd = Get-Command 'Set-PveFirewallRule' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Set-PveFirewallRule' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Set-PveFirewallRule' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Set-PveFirewallRule' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } Context 'Parameter metadata' { It 'Should have mandatory Level parameter with ValidateSet' { - Skip-IfMissing 'Set-PveFirewallRule' $param = $script:Cmd.Parameters['Level'] $param | Should -Not -BeNullOrEmpty $isMandatory = $param.ParameterSets.Values | Where-Object { $_.IsMandatory } @@ -201,16 +114,10 @@ Describe 'Set-PveFirewallRule' { $validateSet = $param.Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } $validateSet | Should -Not -BeNullOrEmpty } - - It 'Should have Position parameter' { - Skip-IfMissing 'Set-PveFirewallRule' - $script:Cmd.Parameters.ContainsKey('Position') | Should -BeTrue - } } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Set-PveFirewallRule' { Set-PveFirewallRule -Level 'cluster' -Position 0 -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -218,14 +125,12 @@ Describe 'Set-PveFirewallRule' { Context 'Group level' { It 'Should include Group in the Level ValidateSet' { - Skip-IfMissing 'Set-PveFirewallRule' $param = $script:Cmd.Parameters['Level'] $validateSet = $param.Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } $validateSet.ValidValues | Should -Contain 'Group' } It 'Should throw when Level is Group and Group is not specified' { - Skip-IfMissing 'Set-PveFirewallRule' { Set-PveFirewallRule -Level 'Group' -Position 0 -ErrorAction Stop } | Should -Throw '*Group is required when Level is Group*' } @@ -236,24 +141,14 @@ Describe 'Set-PveFirewallRule' { # Remove-PveFirewallRule # --------------------------------------------------------------------------- Describe 'Remove-PveFirewallRule' { - - BeforeAll { $script:Cmd = Get-Command 'Remove-PveFirewallRule' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Remove-PveFirewallRule' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Remove-PveFirewallRule' } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { - Skip-IfMissing 'Remove-PveFirewallRule' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High' { - Skip-IfMissing 'Remove-PveFirewallRule' $attr = $script:Cmd.ImplementingType.GetCustomAttributes( [System.Management.Automation.CmdletAttribute], $false) | Select-Object -First 1 @@ -263,7 +158,6 @@ Describe 'Remove-PveFirewallRule' { Context 'Parameter metadata' { It 'Should have mandatory Level parameter with ValidateSet' { - Skip-IfMissing 'Remove-PveFirewallRule' $param = $script:Cmd.Parameters['Level'] $param | Should -Not -BeNullOrEmpty $isMandatory = $param.ParameterSets.Values | Where-Object { $_.IsMandatory } @@ -271,16 +165,10 @@ Describe 'Remove-PveFirewallRule' { $validateSet = $param.Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } $validateSet | Should -Not -BeNullOrEmpty } - - It 'Should have Position parameter' { - Skip-IfMissing 'Remove-PveFirewallRule' - $script:Cmd.Parameters.ContainsKey('Position') | Should -BeTrue - } } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Remove-PveFirewallRule' { Remove-PveFirewallRule -Level 'cluster' -Position 0 -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -288,14 +176,12 @@ Describe 'Remove-PveFirewallRule' { Context 'Group level' { It 'Should include Group in the Level ValidateSet' { - Skip-IfMissing 'Remove-PveFirewallRule' $param = $script:Cmd.Parameters['Level'] $validateSet = $param.Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } $validateSet.ValidValues | Should -Contain 'Group' } It 'Should throw when Level is Group and Group is not specified' { - Skip-IfMissing 'Remove-PveFirewallRule' { Remove-PveFirewallRule -Level 'Group' -Position 0 -Confirm:$false -ErrorAction Stop } | Should -Throw '*Group is required when Level is Group*' } diff --git a/tests/PSProxmoxVE.Tests/HA/HaCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/HA/HaCmdlets.Tests.ps1 index 02e4b4a..1b5c82d 100644 --- a/tests/PSProxmoxVE.Tests/HA/HaCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/HA/HaCmdlets.Tests.ps1 @@ -9,77 +9,20 @@ Get-PveHaRule, New-PveHaRule, Set-PveHaRule, Remove-PveHaRule. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:Availability = @{} - foreach ($name in @( - 'Get-PveHaResource', - 'New-PveHaResource', - 'Set-PveHaResource', - 'Remove-PveHaResource', - 'Move-PveHaResource', - 'Get-PveHaGroup', - 'New-PveHaGroup', - 'Set-PveHaGroup', - 'Remove-PveHaGroup', - 'Get-PveHaStatus', - 'Get-PveHaRule', - 'New-PveHaRule', - 'Set-PveHaRule', - 'Remove-PveHaRule' - )) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } } # --------------------------------------------------------------------------- # Get-PveHaResource # --------------------------------------------------------------------------- Describe 'Get-PveHaResource' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveHaResource' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveHaResource' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveHaResource' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Parameter metadata' { - It 'Should have optional Sid parameter' { - Skip-IfMissing 'Get-PveHaResource' - $script:Cmd.Parameters.ContainsKey('Sid') | Should -BeTrue - } - It 'Sid should not be Mandatory' { - Skip-IfMissing 'Get-PveHaResource' - $p = $script:Cmd.Parameters['Sid'] - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveHaResource' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveHaResource' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveHaResource' { Get-PveHaResource -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -90,41 +33,16 @@ Describe 'Get-PveHaResource' -Tag 'Unit' { # New-PveHaResource # --------------------------------------------------------------------------- Describe 'New-PveHaResource' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'New-PveHaResource' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PveHaResource' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'New-PveHaResource' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'New-PveHaResource' } Context 'Parameter metadata' { - It 'Should have mandatory Sid parameter' { - Skip-IfMissing 'New-PveHaResource' - $p = $script:Cmd.Parameters['Sid'] - $p | Should -Not -BeNullOrEmpty - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } It 'Should have optional State parameter with ValidateSet' { - Skip-IfMissing 'New-PveHaResource' $p = $script:Cmd.Parameters['State'] $p | Should -Not -BeNullOrEmpty $vsAttr = $p.Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } $vsAttr | Should -Not -BeNullOrEmpty } - It 'Should have optional Group parameter' { - Skip-IfMissing 'New-PveHaResource' - $script:Cmd.Parameters.ContainsKey('Group') | Should -BeTrue - } It 'Should have optional MaxRelocate parameter with ValidateRange' { - Skip-IfMissing 'New-PveHaResource' $p = $script:Cmd.Parameters['MaxRelocate'] $p | Should -Not -BeNullOrEmpty $rangeAttr = $p.Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateRangeAttribute] } @@ -133,7 +51,6 @@ Describe 'New-PveHaResource' -Tag 'Unit' { $rangeAttr.MaxRange | Should -Be 10 } It 'Should have optional MaxRestart parameter with ValidateRange' { - Skip-IfMissing 'New-PveHaResource' $p = $script:Cmd.Parameters['MaxRestart'] $p | Should -Not -BeNullOrEmpty $rangeAttr = $p.Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateRangeAttribute] } @@ -141,12 +58,7 @@ Describe 'New-PveHaResource' -Tag 'Unit' { $rangeAttr.MinRange | Should -Be 0 $rangeAttr.MaxRange | Should -Be 10 } - It 'Should have Session parameter' { - Skip-IfMissing 'New-PveHaResource' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } It 'Should support ShouldProcess' { - Skip-IfMissing 'New-PveHaResource' $cmdletAttr = $script:Cmd.ImplementingType.GetCustomAttributes($true) | Where-Object { $_ -is [System.Management.Automation.CmdletAttribute] } $cmdletAttr.SupportsShouldProcess | Should -BeTrue @@ -155,7 +67,6 @@ Describe 'New-PveHaResource' -Tag 'Unit' { Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'New-PveHaResource' { New-PveHaResource -Sid 'vm:100' -ErrorAction Stop -Confirm:$false } | Should -Throw '*No active Proxmox VE session*' } @@ -166,41 +77,16 @@ Describe 'New-PveHaResource' -Tag 'Unit' { # Set-PveHaResource # --------------------------------------------------------------------------- Describe 'Set-PveHaResource' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Set-PveHaResource' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Set-PveHaResource' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Set-PveHaResource' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Set-PveHaResource' } Context 'Parameter metadata' { - It 'Should have mandatory Sid parameter' { - Skip-IfMissing 'Set-PveHaResource' - $p = $script:Cmd.Parameters['Sid'] - $p | Should -Not -BeNullOrEmpty - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } It 'Should have optional State parameter with ValidateSet' { - Skip-IfMissing 'Set-PveHaResource' $p = $script:Cmd.Parameters['State'] $p | Should -Not -BeNullOrEmpty $vsAttr = $p.Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } $vsAttr | Should -Not -BeNullOrEmpty } - It 'Should have Session parameter' { - Skip-IfMissing 'Set-PveHaResource' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } It 'Should support ShouldProcess' { - Skip-IfMissing 'Set-PveHaResource' $cmdletAttr = $script:Cmd.ImplementingType.GetCustomAttributes($true) | Where-Object { $_ -is [System.Management.Automation.CmdletAttribute] } $cmdletAttr.SupportsShouldProcess | Should -BeTrue @@ -209,7 +95,6 @@ Describe 'Set-PveHaResource' -Tag 'Unit' { Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Set-PveHaResource' { Set-PveHaResource -Sid 'vm:100' -ErrorAction Stop -Confirm:$false } | Should -Throw '*No active Proxmox VE session*' } @@ -220,40 +105,15 @@ Describe 'Set-PveHaResource' -Tag 'Unit' { # Remove-PveHaResource # --------------------------------------------------------------------------- Describe 'Remove-PveHaResource' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Remove-PveHaResource' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Remove-PveHaResource' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Remove-PveHaResource' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Remove-PveHaResource' } Context 'Parameter metadata' { - It 'Should have mandatory Sid parameter' { - Skip-IfMissing 'Remove-PveHaResource' - $p = $script:Cmd.Parameters['Sid'] - $p | Should -Not -BeNullOrEmpty - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Should have Session parameter' { - Skip-IfMissing 'Remove-PveHaResource' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } It 'Should support ShouldProcess' { - Skip-IfMissing 'Remove-PveHaResource' $cmdletAttr = $script:Cmd.ImplementingType.GetCustomAttributes($true) | Where-Object { $_ -is [System.Management.Automation.CmdletAttribute] } $cmdletAttr.SupportsShouldProcess | Should -BeTrue } It 'Should have ConfirmImpact High' { - Skip-IfMissing 'Remove-PveHaResource' $cmdletAttr = $script:Cmd.ImplementingType.GetCustomAttributes($true) | Where-Object { $_ -is [System.Management.Automation.CmdletAttribute] } $cmdletAttr.ConfirmImpact | Should -Be 'High' @@ -262,7 +122,6 @@ Describe 'Remove-PveHaResource' -Tag 'Unit' { Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Remove-PveHaResource' { Remove-PveHaResource -Sid 'vm:100' -ErrorAction Stop -Confirm:$false } | Should -Throw '*No active Proxmox VE session*' } @@ -273,37 +132,10 @@ Describe 'Remove-PveHaResource' -Tag 'Unit' { # Move-PveHaResource # --------------------------------------------------------------------------- Describe 'Move-PveHaResource' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Move-PveHaResource' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Move-PveHaResource' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Move-PveHaResource' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Move-PveHaResource' } Context 'Parameter metadata' { - It 'Should have mandatory Sid parameter' { - Skip-IfMissing 'Move-PveHaResource' - $p = $script:Cmd.Parameters['Sid'] - $p | Should -Not -BeNullOrEmpty - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Should have mandatory Node parameter' { - Skip-IfMissing 'Move-PveHaResource' - $p = $script:Cmd.Parameters['Node'] - $p | Should -Not -BeNullOrEmpty - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } It 'Should have Mode parameter with ValidateSet(Migrate, Relocate)' { - Skip-IfMissing 'Move-PveHaResource' $p = $script:Cmd.Parameters['Mode'] $p | Should -Not -BeNullOrEmpty $vsAttr = $p.Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } @@ -311,18 +143,12 @@ Describe 'Move-PveHaResource' -Tag 'Unit' { $vsAttr.ValidValues | Should -Contain 'Migrate' $vsAttr.ValidValues | Should -Contain 'Relocate' } - It 'Should have Session parameter' { - Skip-IfMissing 'Move-PveHaResource' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } It 'Should support ShouldProcess' { - Skip-IfMissing 'Move-PveHaResource' $cmdletAttr = $script:Cmd.ImplementingType.GetCustomAttributes($true) | Where-Object { $_ -is [System.Management.Automation.CmdletAttribute] } $cmdletAttr.SupportsShouldProcess | Should -BeTrue } It 'Should have ConfirmImpact High' { - Skip-IfMissing 'Move-PveHaResource' $cmdletAttr = $script:Cmd.ImplementingType.GetCustomAttributes($true) | Where-Object { $_ -is [System.Management.Automation.CmdletAttribute] } $cmdletAttr.ConfirmImpact | Should -Be 'High' @@ -331,7 +157,6 @@ Describe 'Move-PveHaResource' -Tag 'Unit' { Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Move-PveHaResource' { Move-PveHaResource -Sid 'vm:100' -Node 'pve2' -ErrorAction Stop -Confirm:$false } | Should -Throw '*No active Proxmox VE session*' } @@ -342,40 +167,10 @@ Describe 'Move-PveHaResource' -Tag 'Unit' { # Get-PveHaGroup # --------------------------------------------------------------------------- Describe 'Get-PveHaGroup' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveHaGroup' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveHaGroup' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveHaGroup' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Parameter metadata' { - It 'Should have optional Group parameter' { - Skip-IfMissing 'Get-PveHaGroup' - $script:Cmd.Parameters.ContainsKey('Group') | Should -BeTrue - } - It 'Group should not be Mandatory' { - Skip-IfMissing 'Get-PveHaGroup' - $p = $script:Cmd.Parameters['Group'] - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveHaGroup' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveHaGroup' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveHaGroup' { Get-PveHaGroup -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -386,53 +181,10 @@ Describe 'Get-PveHaGroup' -Tag 'Unit' { # New-PveHaGroup # --------------------------------------------------------------------------- Describe 'New-PveHaGroup' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'New-PveHaGroup' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PveHaGroup' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'New-PveHaGroup' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'New-PveHaGroup' } Context 'Parameter metadata' { - It 'Should have mandatory Group parameter' { - Skip-IfMissing 'New-PveHaGroup' - $p = $script:Cmd.Parameters['Group'] - $p | Should -Not -BeNullOrEmpty - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Should have mandatory Nodes parameter' { - Skip-IfMissing 'New-PveHaGroup' - $p = $script:Cmd.Parameters['Nodes'] - $p | Should -Not -BeNullOrEmpty - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Should have optional Restricted switch' { - Skip-IfMissing 'New-PveHaGroup' - $script:Cmd.Parameters.ContainsKey('Restricted') | Should -BeTrue - } - It 'Should have optional NoFailback switch' { - Skip-IfMissing 'New-PveHaGroup' - $script:Cmd.Parameters.ContainsKey('NoFailback') | Should -BeTrue - } - It 'Should have optional Comment parameter' { - Skip-IfMissing 'New-PveHaGroup' - $script:Cmd.Parameters.ContainsKey('Comment') | Should -BeTrue - } - It 'Should have Session parameter' { - Skip-IfMissing 'New-PveHaGroup' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } It 'Should support ShouldProcess' { - Skip-IfMissing 'New-PveHaGroup' $cmdletAttr = $script:Cmd.ImplementingType.GetCustomAttributes($true) | Where-Object { $_ -is [System.Management.Automation.CmdletAttribute] } $cmdletAttr.SupportsShouldProcess | Should -BeTrue @@ -441,7 +193,6 @@ Describe 'New-PveHaGroup' -Tag 'Unit' { Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'New-PveHaGroup' { New-PveHaGroup -Group 'grp1' -Nodes 'pve1:1,pve2:2' -ErrorAction Stop -Confirm:$false } | Should -Throw '*No active Proxmox VE session*' } @@ -452,34 +203,10 @@ Describe 'New-PveHaGroup' -Tag 'Unit' { # Set-PveHaGroup # --------------------------------------------------------------------------- Describe 'Set-PveHaGroup' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Set-PveHaGroup' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Set-PveHaGroup' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Set-PveHaGroup' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Set-PveHaGroup' } Context 'Parameter metadata' { - It 'Should have mandatory Group parameter' { - Skip-IfMissing 'Set-PveHaGroup' - $p = $script:Cmd.Parameters['Group'] - $p | Should -Not -BeNullOrEmpty - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Should have optional Nodes parameter' { - Skip-IfMissing 'Set-PveHaGroup' - $script:Cmd.Parameters.ContainsKey('Nodes') | Should -BeTrue - } It 'Should have optional Restricted parameter with ValidateRange(0, 1)' { - Skip-IfMissing 'Set-PveHaGroup' $p = $script:Cmd.Parameters['Restricted'] $p | Should -Not -BeNullOrEmpty $rangeAttr = $p.Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateRangeAttribute] } @@ -488,7 +215,6 @@ Describe 'Set-PveHaGroup' -Tag 'Unit' { $rangeAttr.MaxRange | Should -Be 1 } It 'Should have optional NoFailback parameter with ValidateRange(0, 1)' { - Skip-IfMissing 'Set-PveHaGroup' $p = $script:Cmd.Parameters['NoFailback'] $p | Should -Not -BeNullOrEmpty $rangeAttr = $p.Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateRangeAttribute] } @@ -496,12 +222,7 @@ Describe 'Set-PveHaGroup' -Tag 'Unit' { $rangeAttr.MinRange | Should -Be 0 $rangeAttr.MaxRange | Should -Be 1 } - It 'Should have Session parameter' { - Skip-IfMissing 'Set-PveHaGroup' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } It 'Should support ShouldProcess' { - Skip-IfMissing 'Set-PveHaGroup' $cmdletAttr = $script:Cmd.ImplementingType.GetCustomAttributes($true) | Where-Object { $_ -is [System.Management.Automation.CmdletAttribute] } $cmdletAttr.SupportsShouldProcess | Should -BeTrue @@ -510,7 +231,6 @@ Describe 'Set-PveHaGroup' -Tag 'Unit' { Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Set-PveHaGroup' { Set-PveHaGroup -Group 'grp1' -ErrorAction Stop -Confirm:$false } | Should -Throw '*No active Proxmox VE session*' } @@ -521,40 +241,15 @@ Describe 'Set-PveHaGroup' -Tag 'Unit' { # Remove-PveHaGroup # --------------------------------------------------------------------------- Describe 'Remove-PveHaGroup' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Remove-PveHaGroup' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Remove-PveHaGroup' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Remove-PveHaGroup' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Remove-PveHaGroup' } Context 'Parameter metadata' { - It 'Should have mandatory Group parameter' { - Skip-IfMissing 'Remove-PveHaGroup' - $p = $script:Cmd.Parameters['Group'] - $p | Should -Not -BeNullOrEmpty - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Should have Session parameter' { - Skip-IfMissing 'Remove-PveHaGroup' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } It 'Should support ShouldProcess' { - Skip-IfMissing 'Remove-PveHaGroup' $cmdletAttr = $script:Cmd.ImplementingType.GetCustomAttributes($true) | Where-Object { $_ -is [System.Management.Automation.CmdletAttribute] } $cmdletAttr.SupportsShouldProcess | Should -BeTrue } It 'Should have ConfirmImpact High' { - Skip-IfMissing 'Remove-PveHaGroup' $cmdletAttr = $script:Cmd.ImplementingType.GetCustomAttributes($true) | Where-Object { $_ -is [System.Management.Automation.CmdletAttribute] } $cmdletAttr.ConfirmImpact | Should -Be 'High' @@ -563,7 +258,6 @@ Describe 'Remove-PveHaGroup' -Tag 'Unit' { Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Remove-PveHaGroup' { Remove-PveHaGroup -Group 'grp1' -ErrorAction Stop -Confirm:$false } | Should -Throw '*No active Proxmox VE session*' } @@ -574,30 +268,10 @@ Describe 'Remove-PveHaGroup' -Tag 'Unit' { # Get-PveHaStatus # --------------------------------------------------------------------------- Describe 'Get-PveHaStatus' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveHaStatus' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveHaStatus' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveHaStatus' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Parameter metadata' { - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveHaStatus' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveHaStatus' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveHaStatus' { Get-PveHaStatus -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -608,40 +282,10 @@ Describe 'Get-PveHaStatus' -Tag 'Unit' { # Get-PveHaRule # --------------------------------------------------------------------------- Describe 'Get-PveHaRule' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveHaRule' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveHaRule' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveHaRule' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Parameter metadata' { - It 'Should have optional Rule parameter' { - Skip-IfMissing 'Get-PveHaRule' - $script:Cmd.Parameters.ContainsKey('Rule') | Should -BeTrue - } - It 'Rule should not be Mandatory' { - Skip-IfMissing 'Get-PveHaRule' - $p = $script:Cmd.Parameters['Rule'] - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveHaRule' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveHaRule' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveHaRule' { Get-PveHaRule -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -652,49 +296,16 @@ Describe 'Get-PveHaRule' -Tag 'Unit' { # New-PveHaRule # --------------------------------------------------------------------------- Describe 'New-PveHaRule' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'New-PveHaRule' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PveHaRule' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'New-PveHaRule' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'New-PveHaRule' } Context 'Parameter metadata' { - It 'Should have mandatory Type parameter' { - Skip-IfMissing 'New-PveHaRule' - $p = $script:Cmd.Parameters['Type'] - $p | Should -Not -BeNullOrEmpty - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } It 'Should have optional State parameter with ValidateSet' { - Skip-IfMissing 'New-PveHaRule' $p = $script:Cmd.Parameters['State'] $p | Should -Not -BeNullOrEmpty $vsAttr = $p.Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } $vsAttr | Should -Not -BeNullOrEmpty } - It 'Should have optional Comment parameter' { - Skip-IfMissing 'New-PveHaRule' - $script:Cmd.Parameters.ContainsKey('Comment') | Should -BeTrue - } - It 'Should have optional Properties parameter' { - Skip-IfMissing 'New-PveHaRule' - $script:Cmd.Parameters.ContainsKey('Properties') | Should -BeTrue - } - It 'Should have Session parameter' { - Skip-IfMissing 'New-PveHaRule' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } It 'Should support ShouldProcess' { - Skip-IfMissing 'New-PveHaRule' $cmdletAttr = $script:Cmd.ImplementingType.GetCustomAttributes($true) | Where-Object { $_ -is [System.Management.Automation.CmdletAttribute] } $cmdletAttr.SupportsShouldProcess | Should -BeTrue @@ -703,7 +314,6 @@ Describe 'New-PveHaRule' -Tag 'Unit' { Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'New-PveHaRule' { New-PveHaRule -Type 'location' -ErrorAction Stop -Confirm:$false } | Should -Throw '*No active Proxmox VE session*' } @@ -714,52 +324,16 @@ Describe 'New-PveHaRule' -Tag 'Unit' { # Set-PveHaRule # --------------------------------------------------------------------------- Describe 'Set-PveHaRule' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Set-PveHaRule' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Set-PveHaRule' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Set-PveHaRule' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Set-PveHaRule' } Context 'Parameter metadata' { - It 'Should have mandatory Rule parameter' { - Skip-IfMissing 'Set-PveHaRule' - $p = $script:Cmd.Parameters['Rule'] - $p | Should -Not -BeNullOrEmpty - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Should have mandatory Type parameter' { - Skip-IfMissing 'Set-PveHaRule' - $p = $script:Cmd.Parameters['Type'] - $p | Should -Not -BeNullOrEmpty - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } It 'Should have optional State parameter with ValidateSet' { - Skip-IfMissing 'Set-PveHaRule' $p = $script:Cmd.Parameters['State'] $p | Should -Not -BeNullOrEmpty $vsAttr = $p.Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } $vsAttr | Should -Not -BeNullOrEmpty } - It 'Should have optional Properties parameter' { - Skip-IfMissing 'Set-PveHaRule' - $script:Cmd.Parameters.ContainsKey('Properties') | Should -BeTrue - } - It 'Should have Session parameter' { - Skip-IfMissing 'Set-PveHaRule' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } It 'Should support ShouldProcess' { - Skip-IfMissing 'Set-PveHaRule' $cmdletAttr = $script:Cmd.ImplementingType.GetCustomAttributes($true) | Where-Object { $_ -is [System.Management.Automation.CmdletAttribute] } $cmdletAttr.SupportsShouldProcess | Should -BeTrue @@ -768,7 +342,6 @@ Describe 'Set-PveHaRule' -Tag 'Unit' { Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Set-PveHaRule' { Set-PveHaRule -Rule 'rule1' -Type 'node-affinity' -ErrorAction Stop -Confirm:$false } | Should -Throw '*No active Proxmox VE session*' } @@ -779,40 +352,15 @@ Describe 'Set-PveHaRule' -Tag 'Unit' { # Remove-PveHaRule # --------------------------------------------------------------------------- Describe 'Remove-PveHaRule' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Remove-PveHaRule' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Remove-PveHaRule' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Remove-PveHaRule' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Remove-PveHaRule' } Context 'Parameter metadata' { - It 'Should have mandatory Rule parameter' { - Skip-IfMissing 'Remove-PveHaRule' - $p = $script:Cmd.Parameters['Rule'] - $p | Should -Not -BeNullOrEmpty - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Should have Session parameter' { - Skip-IfMissing 'Remove-PveHaRule' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } It 'Should support ShouldProcess' { - Skip-IfMissing 'Remove-PveHaRule' $cmdletAttr = $script:Cmd.ImplementingType.GetCustomAttributes($true) | Where-Object { $_ -is [System.Management.Automation.CmdletAttribute] } $cmdletAttr.SupportsShouldProcess | Should -BeTrue } It 'Should have ConfirmImpact High' { - Skip-IfMissing 'Remove-PveHaRule' $cmdletAttr = $script:Cmd.ImplementingType.GetCustomAttributes($true) | Where-Object { $_ -is [System.Management.Automation.CmdletAttribute] } $cmdletAttr.ConfirmImpact | Should -Be 'High' @@ -821,7 +369,6 @@ Describe 'Remove-PveHaRule' -Tag 'Unit' { Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Remove-PveHaRule' { Remove-PveHaRule -Rule 'rule1' -ErrorAction Stop -Confirm:$false } | Should -Throw '*No active Proxmox VE session*' } diff --git a/tests/PSProxmoxVE.Tests/Module/ManifestExports.Tests.ps1 b/tests/PSProxmoxVE.Tests/Module/ManifestExports.Tests.ps1 new file mode 100644 index 0000000..317b584 --- /dev/null +++ b/tests/PSProxmoxVE.Tests/Module/ManifestExports.Tests.ps1 @@ -0,0 +1,112 @@ +#Requires -Module Pester +<# +.SYNOPSIS + Module-surface contract for PSProxmoxVE. + + Diffs the hand-maintained CmdletsToExport list in the manifest against the + cmdlets the built assembly actually carries, in both directions, and checks + the per-cmdlet conventions from CLAUDE.md that reflection can see. + + All tests are fully offline — no live Proxmox VE target is required. +#> + +BeforeAll { + . $PSScriptRoot/../_TestHelper.ps1 + + $script:Module = Get-Module PSProxmoxVE + $script:Manifest = Import-PowerShellDataFile (Join-Path $script:Module.ModuleBase 'PSProxmoxVE.psd1') + $script:Declared = @($script:Manifest.CmdletsToExport) + $script:Exported = @($script:Module.ExportedCmdlets.Keys) + + # PowerShell intersects CmdletsToExport with what the binary provides, so + # ExportedCmdlets cannot reveal a cmdlet the manifest failed to declare. + # Take the assembly from the loaded appdomain rather than from an export, + # so an empty CmdletsToExport still reaches the assertions below. + $script:Assembly = [AppDomain]::CurrentDomain.GetAssemblies() | + Where-Object { $_.GetName().Name -eq 'PSProxmoxVE' } | + Select-Object -First 1 + + # GetTypes() throws if any one type fails to load; the types that did load + # still answer the question this file asks. + try { $allTypes = $script:Assembly.GetTypes() } + catch { + # PowerShell wraps a .NET exception thrown from a method call, so walk + # down to the load exception that carries the partial type list. + $loadError = $_.Exception + while ($null -ne $loadError -and $loadError -isnot [System.Reflection.ReflectionTypeLoadException]) { + $loadError = $loadError.InnerException + } + if ($null -eq $loadError) { throw } + $allTypes = $loadError.Types | Where-Object { $null -ne $_ } + } + + $script:CmdletTypes = @($allTypes | Where-Object { + -not $_.IsAbstract -and + $_.GetCustomAttributes([System.Management.Automation.CmdletAttribute], $false).Count -gt 0 + }) + + $script:Implemented = @($script:CmdletTypes | ForEach-Object { + $attr = $_.GetCustomAttributes([System.Management.Automation.CmdletAttribute], $false)[0] + '{0}-{1}' -f $attr.VerbName, $attr.NounName + }) + + $script:Because = "module under test: $($script:Module.ModuleBase)" +} + +Describe 'Module manifest' -Tag 'Unit' { + + It 'Finds the module, its manifest and its cmdlet types' { + $script:Assembly | Should -Not -BeNullOrEmpty -Because $script:Because + $script:Implemented.Count | Should -BeGreaterThan 0 -Because $script:Because + $script:Declared.Count | Should -BeGreaterThan 0 -Because $script:Because + } + + It 'Declares every cmdlet the assembly implements' { + $undeclared = @($script:Implemented | Where-Object { $script:Declared -notcontains $_ } | Sort-Object) + $undeclared -join ', ' | Should -BeNullOrEmpty -Because "a cmdlet the assembly carries but the manifest does not declare never reaches users ($script:Because)" + } + + It 'Exports every name the manifest declares' { + $unexported = @($script:Declared | Where-Object { $script:Exported -notcontains $_ } | Sort-Object) + $unexported -join ', ' | Should -BeNullOrEmpty -Because "the manifest declares a name the imported module does not export ($script:Because)" + } + + It 'Lists each cmdlet once' { + $duplicates = @($script:Declared | Group-Object | Where-Object Count -gt 1 | ForEach-Object Name | Sort-Object) + $duplicates -join ', ' | Should -BeNullOrEmpty -Because 'CmdletsToExport repeats these names' + } +} + +Describe 'Cmdlet conventions' -Tag 'Unit' { + + It 'Every cmdlet class is sealed' { + $unsealed = @($script:CmdletTypes | Where-Object { -not $_.IsSealed } | ForEach-Object FullName | Sort-Object) + $unsealed -join ', ' | Should -BeNullOrEmpty -Because 'cmdlet classes must be sealed' + } + + It 'Every cmdlet class declares its own [OutputType]' { + $missing = @($script:CmdletTypes | Where-Object { + $_.GetCustomAttributes([System.Management.Automation.OutputTypeAttribute], $false).Count -eq 0 + } | ForEach-Object FullName | Sort-Object) + $missing -join ', ' | Should -BeNullOrEmpty -Because 'an inherited [OutputType] would not describe the derived cmdlet' + } + + It 'Every cmdlet uses the Pve noun prefix' { + $offenders = @($script:Implemented | Where-Object { $_ -cnotmatch '^[A-Z]\w*-Pve[A-Z]\w*$' } | Sort-Object) + $offenders -join ', ' | Should -BeNullOrEmpty -Because 'all cmdlets use the Pve noun prefix' + } + + It 'Every cmdlet derived from PveCmdletBase exposes -Session' { + $baseType = $script:Assembly.GetType('PSProxmoxVE.Cmdlets.PveCmdletBase') + $baseType | Should -Not -BeNullOrEmpty + $missing = @($script:CmdletTypes | + Where-Object { $_.IsSubclassOf($baseType) } | + ForEach-Object { + $attr = $_.GetCustomAttributes([System.Management.Automation.CmdletAttribute], $false)[0] + '{0}-{1}' -f $attr.VerbName, $attr.NounName + } | + Where-Object { -not (Get-Command $_).Parameters.ContainsKey('Session') } | + Sort-Object) + $missing -join ', ' | Should -BeNullOrEmpty -Because '-Session is inherited from PveCmdletBase and is part of every such cmdlet''s surface' + } +} diff --git a/tests/PSProxmoxVE.Tests/Network/Get-PveNetwork.Tests.ps1 b/tests/PSProxmoxVE.Tests/Network/Get-PveNetwork.Tests.ps1 index e34d19a..d9890f6 100644 --- a/tests/PSProxmoxVE.Tests/Network/Get-PveNetwork.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Network/Get-PveNetwork.Tests.ps1 @@ -6,90 +6,20 @@ Remove-PveNetwork, Invoke-PveNetworkApply. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:Availability = @{} - foreach ($name in @('Get-PveNetwork', 'New-PveNetwork', 'Set-PveNetwork', - 'Remove-PveNetwork', 'Invoke-PveNetworkApply')) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } -} - -# --------------------------------------------------------------------------- -# Manifest contract -# --------------------------------------------------------------------------- -Describe 'Network cmdlets — manifest declarations' { - BeforeAll { - $manifestPath = Join-Path (Get-Module PSProxmoxVE).ModuleBase 'PSProxmoxVE.psd1' - $script:Manifest = if (Test-Path $manifestPath) { Import-PowerShellDataFile $manifestPath } else { $null } - } - - It " should be declared in CmdletsToExport" -TestCases @( - @{ cmdName = 'Get-PveNetwork' } - @{ cmdName = 'New-PveNetwork' } - @{ cmdName = 'Set-PveNetwork' } - @{ cmdName = 'Remove-PveNetwork' } - @{ cmdName = 'Invoke-PveNetworkApply' } - ) { - if ($null -eq $script:Manifest) { Set-ItResult -Skipped -Because 'Manifest not found'; return } - $script:Manifest.CmdletsToExport | Should -Contain $cmdName - } } # --------------------------------------------------------------------------- # Get-PveNetwork # --------------------------------------------------------------------------- Describe 'Get-PveNetwork' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveNetwork' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveNetwork' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveNetwork' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Parameter metadata' { - It 'Should have Node parameter (Mandatory — network is always node-specific)' { - Skip-IfMissing 'Get-PveNetwork' - $script:Cmd.Parameters.ContainsKey('Node') | Should -BeTrue - } - - It 'Should have Iface parameter (optional filter)' { - Skip-IfMissing 'Get-PveNetwork' - $script:Cmd.Parameters.ContainsKey('Iface') | Should -BeTrue - } - - It 'Should have Type parameter (optional filter by interface type)' { - Skip-IfMissing 'Get-PveNetwork' - $script:Cmd.Parameters.ContainsKey('Type') | Should -BeTrue - } - - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveNetwork' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveNetwork' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveNetwork' { Get-PveNetwork -Node 'pve-node1' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -100,176 +30,73 @@ Describe 'Get-PveNetwork' { # New-PveNetwork # --------------------------------------------------------------------------- Describe 'New-PveNetwork' { - - BeforeAll { $script:Cmd = Get-Command 'New-PveNetwork' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PveNetwork' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'New-PveNetwork' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'New-PveNetwork' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } Context 'VLAN-aware bridge' { It 'Should expose BridgeVlanAware as a switch' { - Skip-IfMissing 'New-PveNetwork' $script:Cmd.Parameters.ContainsKey('BridgeVlanAware') | Should -BeTrue $script:Cmd.Parameters['BridgeVlanAware'].ParameterType | Should -Be ([System.Management.Automation.SwitchParameter]) } } - - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'New-PveNetwork' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Iface should be Mandatory' { - Skip-IfMissing 'New-PveNetwork' - $isMandatory = $script:Cmd.Parameters['Iface'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Type should be Mandatory' { - Skip-IfMissing 'New-PveNetwork' - $isMandatory = $script:Cmd.Parameters['Type'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } } # --------------------------------------------------------------------------- # Set-PveNetwork # --------------------------------------------------------------------------- Describe 'Set-PveNetwork' { - - BeforeAll { $script:Cmd = Get-Command 'Set-PveNetwork' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Set-PveNetwork' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Set-PveNetwork' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Set-PveNetwork' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } Context 'VLAN-aware bridge' { It 'Should expose BridgeVlanAware as a switch' { - Skip-IfMissing 'Set-PveNetwork' $script:Cmd.Parameters.ContainsKey('BridgeVlanAware') | Should -BeTrue $script:Cmd.Parameters['BridgeVlanAware'].ParameterType | Should -Be ([System.Management.Automation.SwitchParameter]) } } - - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Set-PveNetwork' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Iface should be Mandatory' { - Skip-IfMissing 'Set-PveNetwork' - $isMandatory = $script:Cmd.Parameters['Iface'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } } # --------------------------------------------------------------------------- # Remove-PveNetwork # --------------------------------------------------------------------------- Describe 'Remove-PveNetwork' { - - BeforeAll { $script:Cmd = Get-Command 'Remove-PveNetwork' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Remove-PveNetwork' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Remove-PveNetwork' } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { - Skip-IfMissing 'Remove-PveNetwork' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High' { - Skip-IfMissing 'Remove-PveNetwork' $attr = $script:Cmd.ImplementingType.GetCustomAttributes( [System.Management.Automation.CmdletAttribute], $false) | Select-Object -First 1 $attr.ConfirmImpact | Should -Be ([System.Management.Automation.ConfirmImpact]::High) } } - - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Remove-PveNetwork' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Iface should be Mandatory' { - Skip-IfMissing 'Remove-PveNetwork' - $isMandatory = $script:Cmd.Parameters['Iface'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } } # --------------------------------------------------------------------------- # Invoke-PveNetworkApply # --------------------------------------------------------------------------- Describe 'Invoke-PveNetworkApply' { - - BeforeAll { $script:Cmd = Get-Command 'Invoke-PveNetworkApply' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Invoke-PveNetworkApply' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Invoke-PveNetworkApply' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Invoke-PveNetworkApply' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Invoke-PveNetworkApply' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } } diff --git a/tests/PSProxmoxVE.Tests/Network/SdnCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Network/SdnCmdlets.Tests.ps1 index 1cd7e7f..b12fcfa 100644 --- a/tests/PSProxmoxVE.Tests/Network/SdnCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Network/SdnCmdlets.Tests.ps1 @@ -20,75 +20,16 @@ BeforeAll { 'Get-PveSdnZone', 'New-PveSdnZone', 'Remove-PveSdnZone', 'Get-PveSdnVnet', 'New-PveSdnVnet', 'Remove-PveSdnVnet' ) - - $script:Availability = @{} - foreach ($name in $script:SdnCmdlets) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } -} - -# --------------------------------------------------------------------------- -# Manifest contract -# --------------------------------------------------------------------------- -Describe 'SDN cmdlets — manifest declarations' { - BeforeAll { - $manifestPath = Join-Path (Get-Module PSProxmoxVE).ModuleBase 'PSProxmoxVE.psd1' - $script:Manifest = if (Test-Path $manifestPath) { Import-PowerShellDataFile $manifestPath } else { $null } - } - - It " should be declared in CmdletsToExport" -TestCases @( - @{ cmdName = 'Get-PveSdnZone' } - @{ cmdName = 'New-PveSdnZone' } - @{ cmdName = 'Remove-PveSdnZone' } - @{ cmdName = 'Get-PveSdnVnet' } - @{ cmdName = 'New-PveSdnVnet' } - @{ cmdName = 'Remove-PveSdnVnet' } - ) { - if ($null -eq $script:Manifest) { Set-ItResult -Skipped -Because 'Manifest not found'; return } - $script:Manifest.CmdletsToExport | Should -Contain $cmdName - } } # --------------------------------------------------------------------------- # Get-PveSdnZone # --------------------------------------------------------------------------- Describe 'Get-PveSdnZone' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveSdnZone' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveSdnZone' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveSdnZone' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Parameter metadata' { - It 'Should have Zone parameter (optional filter by zone ID)' { - Skip-IfMissing 'Get-PveSdnZone' - $script:Cmd.Parameters.ContainsKey('Zone') | Should -BeTrue - } - - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveSdnZone' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveSdnZone' } Context 'Version guard behaviour — without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveSdnZone' { Get-PveSdnZone -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -99,51 +40,21 @@ Describe 'Get-PveSdnZone' { # New-PveSdnZone # --------------------------------------------------------------------------- Describe 'New-PveSdnZone' { - - BeforeAll { $script:Cmd = Get-Command 'New-PveSdnZone' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PveSdnZone' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'New-PveSdnZone' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'New-PveSdnZone' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Zone should be Mandatory' { - Skip-IfMissing 'New-PveSdnZone' - $isMandatory = $script:Cmd.Parameters['Zone'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Type should be Mandatory' { - Skip-IfMissing 'New-PveSdnZone' - $isMandatory = $script:Cmd.Parameters['Type'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Type ValidateSet' { It 'Type parameter should have ValidateSet including known zone types' { - Skip-IfMissing 'New-PveSdnZone' $validateSetAttr = $script:Cmd.Parameters['Type'].Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } | Select-Object -First 1 - if ($null -ne $validateSetAttr) { - $validateSetAttr.ValidValues | Should -Contain 'simple' - } - else { - Set-ItResult -Skipped -Because 'Type does not use a ValidateSet attribute in this build' - } + $validateSetAttr | Should -Not -BeNullOrEmpty + $validateSetAttr.ValidValues | Should -Contain 'simple' } } } @@ -152,75 +63,30 @@ Describe 'New-PveSdnZone' { # Remove-PveSdnZone # --------------------------------------------------------------------------- Describe 'Remove-PveSdnZone' { - - BeforeAll { $script:Cmd = Get-Command 'Remove-PveSdnZone' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Remove-PveSdnZone' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Remove-PveSdnZone' } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { - Skip-IfMissing 'Remove-PveSdnZone' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High' { - Skip-IfMissing 'Remove-PveSdnZone' $attr = $script:Cmd.ImplementingType.GetCustomAttributes( [System.Management.Automation.CmdletAttribute], $false) | Select-Object -First 1 $attr.ConfirmImpact | Should -Be ([System.Management.Automation.ConfirmImpact]::High) } } - - Context 'Required parameters' { - It 'Zone should be Mandatory' { - Skip-IfMissing 'Remove-PveSdnZone' - $isMandatory = $script:Cmd.Parameters['Zone'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } } # --------------------------------------------------------------------------- # Get-PveSdnVnet # --------------------------------------------------------------------------- Describe 'Get-PveSdnVnet' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveSdnVnet' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveSdnVnet' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } - - Context 'Parameter metadata' { - It 'Should have Vnet parameter (optional filter by VNet name)' { - Skip-IfMissing 'Get-PveSdnVnet' - $script:Cmd.Parameters.ContainsKey('Vnet') | Should -BeTrue - } - - It 'Should have Zone parameter (optional filter by parent zone)' { - Skip-IfMissing 'Get-PveSdnVnet' - $script:Cmd.Parameters.ContainsKey('Zone') | Should -BeTrue - } - - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveSdnVnet' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveSdnVnet' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveSdnVnet' { Get-PveSdnVnet -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -231,75 +97,31 @@ Describe 'Get-PveSdnVnet' { # New-PveSdnVnet # --------------------------------------------------------------------------- Describe 'New-PveSdnVnet' { - - BeforeAll { $script:Cmd = Get-Command 'New-PveSdnVnet' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PveSdnVnet' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'New-PveSdnVnet' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'New-PveSdnVnet' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - - Context 'Required parameters' { - It 'Vnet should be Mandatory' { - Skip-IfMissing 'New-PveSdnVnet' - $isMandatory = $script:Cmd.Parameters['Vnet'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Zone should be Mandatory' { - Skip-IfMissing 'New-PveSdnVnet' - $isMandatory = $script:Cmd.Parameters['Zone'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } } # --------------------------------------------------------------------------- # Remove-PveSdnVnet # --------------------------------------------------------------------------- Describe 'Remove-PveSdnVnet' { - - BeforeAll { $script:Cmd = Get-Command 'Remove-PveSdnVnet' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Remove-PveSdnVnet' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Remove-PveSdnVnet' } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { - Skip-IfMissing 'Remove-PveSdnVnet' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High' { - Skip-IfMissing 'Remove-PveSdnVnet' $attr = $script:Cmd.ImplementingType.GetCustomAttributes( [System.Management.Automation.CmdletAttribute], $false) | Select-Object -First 1 $attr.ConfirmImpact | Should -Be ([System.Management.Automation.ConfirmImpact]::High) } } - - Context 'Required parameters' { - It 'Vnet should be Mandatory' { - Skip-IfMissing 'Remove-PveSdnVnet' - $isMandatory = $script:Cmd.Parameters['Vnet'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } } diff --git a/tests/PSProxmoxVE.Tests/Network/SdnIpamDnsControllerCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Network/SdnIpamDnsControllerCmdlets.Tests.ps1 index 6f2fa8a..ca25c8d 100644 --- a/tests/PSProxmoxVE.Tests/Network/SdnIpamDnsControllerCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Network/SdnIpamDnsControllerCmdlets.Tests.ps1 @@ -7,51 +7,10 @@ Get-PveSdnController, New-PveSdnController, Remove-PveSdnController. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:Availability = @{} - foreach ($name in @( - 'Get-PveSdnIpam', 'New-PveSdnIpam', 'Remove-PveSdnIpam', - 'Get-PveSdnDns', 'New-PveSdnDns', 'Remove-PveSdnDns', - 'Get-PveSdnController', 'New-PveSdnController', 'Remove-PveSdnController' - )) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } -} - -# --------------------------------------------------------------------------- -# Manifest contract -# --------------------------------------------------------------------------- -Describe 'SDN IPAM/DNS/Controller cmdlets — manifest declarations' { - BeforeAll { - $manifestPath = Join-Path (Get-Module PSProxmoxVE).ModuleBase 'PSProxmoxVE.psd1' - $script:Manifest = if (Test-Path $manifestPath) { Import-PowerShellDataFile $manifestPath } else { $null } - } - - It " should be declared in CmdletsToExport" -TestCases @( - @{ cmdName = 'Get-PveSdnIpam' } - @{ cmdName = 'New-PveSdnIpam' } - @{ cmdName = 'Remove-PveSdnIpam' } - @{ cmdName = 'Get-PveSdnDns' } - @{ cmdName = 'New-PveSdnDns' } - @{ cmdName = 'Remove-PveSdnDns' } - @{ cmdName = 'Get-PveSdnController' } - @{ cmdName = 'New-PveSdnController' } - @{ cmdName = 'Remove-PveSdnController' } - ) { - if ($null -eq $script:Manifest) { Set-ItResult -Skipped -Because 'Manifest not found'; return } - $script:Manifest.CmdletsToExport | Should -Contain $cmdName - } } # =========================================================================== @@ -62,36 +21,10 @@ Describe 'SDN IPAM/DNS/Controller cmdlets — manifest declarations' { # Get-PveSdnIpam # --------------------------------------------------------------------------- Describe 'Get-PveSdnIpam' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveSdnIpam' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveSdnIpam' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveSdnIpam' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Parameter metadata' { - It 'Should have optional Ipam parameter' { - Skip-IfMissing 'Get-PveSdnIpam' - $script:Cmd.Parameters.ContainsKey('Ipam') | Should -BeTrue - } - - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveSdnIpam' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveSdnIpam' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveSdnIpam' { Get-PveSdnIpam -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -102,42 +35,16 @@ Describe 'Get-PveSdnIpam' { # New-PveSdnIpam # --------------------------------------------------------------------------- Describe 'New-PveSdnIpam' { - - BeforeAll { $script:Cmd = Get-Command 'New-PveSdnIpam' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PveSdnIpam' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'New-PveSdnIpam' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'New-PveSdnIpam' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Ipam should be Mandatory' { - Skip-IfMissing 'New-PveSdnIpam' - $isMandatory = $script:Cmd.Parameters['Ipam'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Type should be Mandatory' { - Skip-IfMissing 'New-PveSdnIpam' - $isMandatory = $script:Cmd.Parameters['Type'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'New-PveSdnIpam' { New-PveSdnIpam -Ipam 'testipam' -Type 'pve' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -148,24 +55,14 @@ Describe 'New-PveSdnIpam' { # Remove-PveSdnIpam # --------------------------------------------------------------------------- Describe 'Remove-PveSdnIpam' { - - BeforeAll { $script:Cmd = Get-Command 'Remove-PveSdnIpam' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Remove-PveSdnIpam' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Remove-PveSdnIpam' } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { - Skip-IfMissing 'Remove-PveSdnIpam' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High' { - Skip-IfMissing 'Remove-PveSdnIpam' $attr = $script:Cmd.ImplementingType.GetCustomAttributes( [System.Management.Automation.CmdletAttribute], $false) | Select-Object -First 1 @@ -173,18 +70,8 @@ Describe 'Remove-PveSdnIpam' { } } - Context 'Required parameters' { - It 'Ipam should be Mandatory' { - Skip-IfMissing 'Remove-PveSdnIpam' - $isMandatory = $script:Cmd.Parameters['Ipam'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Remove-PveSdnIpam' { Remove-PveSdnIpam -Ipam 'testipam' -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -199,36 +86,10 @@ Describe 'Remove-PveSdnIpam' { # Get-PveSdnDns # --------------------------------------------------------------------------- Describe 'Get-PveSdnDns' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveSdnDns' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveSdnDns' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveSdnDns' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Parameter metadata' { - It 'Should have optional Dns parameter' { - Skip-IfMissing 'Get-PveSdnDns' - $script:Cmd.Parameters.ContainsKey('Dns') | Should -BeTrue - } - - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveSdnDns' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveSdnDns' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveSdnDns' { Get-PveSdnDns -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -239,42 +100,16 @@ Describe 'Get-PveSdnDns' { # New-PveSdnDns # --------------------------------------------------------------------------- Describe 'New-PveSdnDns' { - - BeforeAll { $script:Cmd = Get-Command 'New-PveSdnDns' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PveSdnDns' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'New-PveSdnDns' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'New-PveSdnDns' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Dns should be Mandatory' { - Skip-IfMissing 'New-PveSdnDns' - $isMandatory = $script:Cmd.Parameters['Dns'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Type should be Mandatory' { - Skip-IfMissing 'New-PveSdnDns' - $isMandatory = $script:Cmd.Parameters['Type'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'New-PveSdnDns' { New-PveSdnDns -Dns 'testdns' -Type 'powerdns' -Url 'http://localhost:8081' -Key 'testkey' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -285,24 +120,14 @@ Describe 'New-PveSdnDns' { # Remove-PveSdnDns # --------------------------------------------------------------------------- Describe 'Remove-PveSdnDns' { - - BeforeAll { $script:Cmd = Get-Command 'Remove-PveSdnDns' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Remove-PveSdnDns' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Remove-PveSdnDns' } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { - Skip-IfMissing 'Remove-PveSdnDns' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High' { - Skip-IfMissing 'Remove-PveSdnDns' $attr = $script:Cmd.ImplementingType.GetCustomAttributes( [System.Management.Automation.CmdletAttribute], $false) | Select-Object -First 1 @@ -310,18 +135,8 @@ Describe 'Remove-PveSdnDns' { } } - Context 'Required parameters' { - It 'Dns should be Mandatory' { - Skip-IfMissing 'Remove-PveSdnDns' - $isMandatory = $script:Cmd.Parameters['Dns'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Remove-PveSdnDns' { Remove-PveSdnDns -Dns 'testdns' -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -336,36 +151,10 @@ Describe 'Remove-PveSdnDns' { # Get-PveSdnController # --------------------------------------------------------------------------- Describe 'Get-PveSdnController' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveSdnController' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveSdnController' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveSdnController' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Parameter metadata' { - It 'Should have optional Controller parameter' { - Skip-IfMissing 'Get-PveSdnController' - $script:Cmd.Parameters.ContainsKey('Controller') | Should -BeTrue - } - - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveSdnController' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveSdnController' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveSdnController' { Get-PveSdnController -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -376,42 +165,16 @@ Describe 'Get-PveSdnController' { # New-PveSdnController # --------------------------------------------------------------------------- Describe 'New-PveSdnController' { - - BeforeAll { $script:Cmd = Get-Command 'New-PveSdnController' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PveSdnController' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'New-PveSdnController' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'New-PveSdnController' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Controller should be Mandatory' { - Skip-IfMissing 'New-PveSdnController' - $isMandatory = $script:Cmd.Parameters['Controller'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Type should be Mandatory' { - Skip-IfMissing 'New-PveSdnController' - $isMandatory = $script:Cmd.Parameters['Type'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'New-PveSdnController' { New-PveSdnController -Controller 'testctrl' -Type 'evpn' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -422,24 +185,14 @@ Describe 'New-PveSdnController' { # Remove-PveSdnController # --------------------------------------------------------------------------- Describe 'Remove-PveSdnController' { - - BeforeAll { $script:Cmd = Get-Command 'Remove-PveSdnController' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Remove-PveSdnController' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Remove-PveSdnController' } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { - Skip-IfMissing 'Remove-PveSdnController' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High' { - Skip-IfMissing 'Remove-PveSdnController' $attr = $script:Cmd.ImplementingType.GetCustomAttributes( [System.Management.Automation.CmdletAttribute], $false) | Select-Object -First 1 @@ -447,18 +200,8 @@ Describe 'Remove-PveSdnController' { } } - Context 'Required parameters' { - It 'Controller should be Mandatory' { - Skip-IfMissing 'Remove-PveSdnController' - $isMandatory = $script:Cmd.Parameters['Controller'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Remove-PveSdnController' { Remove-PveSdnController -Controller 'testctrl' -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } diff --git a/tests/PSProxmoxVE.Tests/Network/SdnSetCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Network/SdnSetCmdlets.Tests.ps1 index dacebdd..3cffdde 100644 --- a/tests/PSProxmoxVE.Tests/Network/SdnSetCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Network/SdnSetCmdlets.Tests.ps1 @@ -6,64 +6,26 @@ Set-PveSdnIpam, Set-PveSdnDns, Invoke-PveSdnApply, Set-PveRole, Set-PveApiToken. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:Availability = @{} - foreach ($name in @( - 'Set-PveSdnZone', 'Set-PveSdnVnet', 'Set-PveSdnSubnet', 'Set-PveSdnController', - 'Set-PveSdnIpam', 'Set-PveSdnDns', 'Invoke-PveSdnApply', 'Set-PveRole', 'Set-PveApiToken' - )) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } } # --------------------------------------------------------------------------- # Set-PveSdnZone # --------------------------------------------------------------------------- Describe 'Set-PveSdnZone' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Set-PveSdnZone' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Set-PveSdnZone' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Set-PveSdnZone' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Set-PveSdnZone' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Set-PveSdnZone' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Zone should be Mandatory' { - Skip-IfMissing 'Set-PveSdnZone' - $isMandatory = $script:Cmd.Parameters['Zone'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Set-PveSdnZone' { Set-PveSdnZone -Zone 'testzone' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -74,39 +36,16 @@ Describe 'Set-PveSdnZone' -Tag 'Unit' { # Set-PveSdnVnet # --------------------------------------------------------------------------- Describe 'Set-PveSdnVnet' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Set-PveSdnVnet' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Set-PveSdnVnet' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Set-PveSdnVnet' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Set-PveSdnVnet' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Set-PveSdnVnet' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Vnet should be Mandatory' { - Skip-IfMissing 'Set-PveSdnVnet' - $isMandatory = $script:Cmd.Parameters['Vnet'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Set-PveSdnVnet' { Set-PveSdnVnet -Vnet 'testvnet' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -117,45 +56,16 @@ Describe 'Set-PveSdnVnet' -Tag 'Unit' { # Set-PveSdnSubnet # --------------------------------------------------------------------------- Describe 'Set-PveSdnSubnet' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Set-PveSdnSubnet' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Set-PveSdnSubnet' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Set-PveSdnSubnet' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Set-PveSdnSubnet' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Set-PveSdnSubnet' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Vnet should be Mandatory' { - Skip-IfMissing 'Set-PveSdnSubnet' - $isMandatory = $script:Cmd.Parameters['Vnet'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Subnet should be Mandatory' { - Skip-IfMissing 'Set-PveSdnSubnet' - $isMandatory = $script:Cmd.Parameters['Subnet'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Set-PveSdnSubnet' { Set-PveSdnSubnet -Vnet 'testvnet' -Subnet '10.0.0.0/24' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -166,39 +76,16 @@ Describe 'Set-PveSdnSubnet' -Tag 'Unit' { # Set-PveSdnController # --------------------------------------------------------------------------- Describe 'Set-PveSdnController' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Set-PveSdnController' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Set-PveSdnController' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Set-PveSdnController' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Set-PveSdnController' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Set-PveSdnController' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Controller should be Mandatory' { - Skip-IfMissing 'Set-PveSdnController' - $isMandatory = $script:Cmd.Parameters['Controller'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Set-PveSdnController' { Set-PveSdnController -Controller 'testctrl' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -209,39 +96,16 @@ Describe 'Set-PveSdnController' -Tag 'Unit' { # Set-PveSdnIpam # --------------------------------------------------------------------------- Describe 'Set-PveSdnIpam' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Set-PveSdnIpam' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Set-PveSdnIpam' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Set-PveSdnIpam' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Set-PveSdnIpam' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Set-PveSdnIpam' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Ipam should be Mandatory' { - Skip-IfMissing 'Set-PveSdnIpam' - $isMandatory = $script:Cmd.Parameters['Ipam'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Set-PveSdnIpam' { Set-PveSdnIpam -Ipam 'testipam' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -252,39 +116,16 @@ Describe 'Set-PveSdnIpam' -Tag 'Unit' { # Set-PveSdnDns # --------------------------------------------------------------------------- Describe 'Set-PveSdnDns' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Set-PveSdnDns' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Set-PveSdnDns' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Set-PveSdnDns' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Set-PveSdnDns' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Set-PveSdnDns' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Dns should be Mandatory' { - Skip-IfMissing 'Set-PveSdnDns' - $isMandatory = $script:Cmd.Parameters['Dns'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Set-PveSdnDns' { Set-PveSdnDns -Dns 'testdns' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -295,30 +136,16 @@ Describe 'Set-PveSdnDns' -Tag 'Unit' { # Invoke-PveSdnApply # --------------------------------------------------------------------------- Describe 'Invoke-PveSdnApply' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Invoke-PveSdnApply' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Invoke-PveSdnApply' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Invoke-PveSdnApply' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Invoke-PveSdnApply' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Invoke-PveSdnApply' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Invoke-PveSdnApply' { Invoke-PveSdnApply -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -329,45 +156,16 @@ Describe 'Invoke-PveSdnApply' -Tag 'Unit' { # Set-PveRole # --------------------------------------------------------------------------- Describe 'Set-PveRole' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Set-PveRole' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Set-PveRole' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Set-PveRole' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Set-PveRole' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Set-PveRole' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'RoleId should be Mandatory' { - Skip-IfMissing 'Set-PveRole' - $isMandatory = $script:Cmd.Parameters['RoleId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Privileges should be Mandatory' { - Skip-IfMissing 'Set-PveRole' - $isMandatory = $script:Cmd.Parameters['Privileges'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Set-PveRole' { Set-PveRole -RoleId 'testrole' -Privileges 'VM.Audit' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -378,45 +176,16 @@ Describe 'Set-PveRole' -Tag 'Unit' { # Set-PveApiToken # --------------------------------------------------------------------------- Describe 'Set-PveApiToken' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Set-PveApiToken' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Set-PveApiToken' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Set-PveApiToken' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Set-PveApiToken' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Set-PveApiToken' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'UserId should be Mandatory' { - Skip-IfMissing 'Set-PveApiToken' - $isMandatory = $script:Cmd.Parameters['UserId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'TokenId should be Mandatory' { - Skip-IfMissing 'Set-PveApiToken' - $isMandatory = $script:Cmd.Parameters['TokenId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Set-PveApiToken' { Set-PveApiToken -UserId 'user@pam' -TokenId 'testtoken' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } diff --git a/tests/PSProxmoxVE.Tests/Network/SdnSubnetCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Network/SdnSubnetCmdlets.Tests.ps1 index e2ee4b7..5c09068 100644 --- a/tests/PSProxmoxVE.Tests/Network/SdnSubnetCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Network/SdnSubnetCmdlets.Tests.ps1 @@ -5,82 +5,20 @@ Get-PveSdnSubnet, New-PveSdnSubnet, Remove-PveSdnSubnet. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:Availability = @{} - foreach ($name in @('Get-PveSdnSubnet', 'New-PveSdnSubnet', 'Remove-PveSdnSubnet')) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } -} - -# --------------------------------------------------------------------------- -# Manifest contract -# --------------------------------------------------------------------------- -Describe 'SDN subnet cmdlets — manifest declarations' { - BeforeAll { - $manifestPath = Join-Path (Get-Module PSProxmoxVE).ModuleBase 'PSProxmoxVE.psd1' - $script:Manifest = if (Test-Path $manifestPath) { Import-PowerShellDataFile $manifestPath } else { $null } - } - - It " should be declared in CmdletsToExport" -TestCases @( - @{ cmdName = 'Get-PveSdnSubnet' } - @{ cmdName = 'New-PveSdnSubnet' } - @{ cmdName = 'Remove-PveSdnSubnet' } - ) { - if ($null -eq $script:Manifest) { Set-ItResult -Skipped -Because 'Manifest not found'; return } - $script:Manifest.CmdletsToExport | Should -Contain $cmdName - } } # --------------------------------------------------------------------------- # Get-PveSdnSubnet # --------------------------------------------------------------------------- Describe 'Get-PveSdnSubnet' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveSdnSubnet' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveSdnSubnet' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveSdnSubnet' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveSdnSubnet' } Context 'Parameter metadata' { - It 'Vnet should be Mandatory' { - Skip-IfMissing 'Get-PveSdnSubnet' - $isMandatory = $script:Cmd.Parameters['Vnet'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Should have Subnet parameter (optional filter)' { - Skip-IfMissing 'Get-PveSdnSubnet' - $script:Cmd.Parameters.ContainsKey('Subnet') | Should -BeTrue - } - - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveSdnSubnet' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - It 'Vnet should accept pipeline input by property name' { - Skip-IfMissing 'Get-PveSdnSubnet' $attr = $script:Cmd.Parameters['Vnet'].ParameterSets.Values | Where-Object { $_.ValueFromPipelineByPropertyName } $attr | Should -Not -BeNullOrEmpty @@ -89,7 +27,6 @@ Describe 'Get-PveSdnSubnet' { Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveSdnSubnet' { Get-PveSdnSubnet -Vnet 'myvnet' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -100,64 +37,16 @@ Describe 'Get-PveSdnSubnet' { # New-PveSdnSubnet # --------------------------------------------------------------------------- Describe 'New-PveSdnSubnet' { - - BeforeAll { $script:Cmd = Get-Command 'New-PveSdnSubnet' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PveSdnSubnet' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'New-PveSdnSubnet' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'New-PveSdnSubnet' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Vnet should be Mandatory' { - Skip-IfMissing 'New-PveSdnSubnet' - $isMandatory = $script:Cmd.Parameters['Vnet'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Subnet should be Mandatory' { - Skip-IfMissing 'New-PveSdnSubnet' - $isMandatory = $script:Cmd.Parameters['Subnet'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - - Context 'Optional parameters' { - It 'Should have Gateway parameter' { - Skip-IfMissing 'New-PveSdnSubnet' - $script:Cmd.Parameters.ContainsKey('Gateway') | Should -BeTrue - } - - It 'Should have Snat switch parameter' { - Skip-IfMissing 'New-PveSdnSubnet' - $script:Cmd.Parameters.ContainsKey('Snat') | Should -BeTrue - } - - It 'Should have DnsZonePrefix parameter' { - Skip-IfMissing 'New-PveSdnSubnet' - $script:Cmd.Parameters.ContainsKey('DnsZonePrefix') | Should -BeTrue - } - - It 'Should have DhcpRange parameter' { - Skip-IfMissing 'New-PveSdnSubnet' - $script:Cmd.Parameters.ContainsKey('DhcpRange') | Should -BeTrue - } - } - Context 'Without active session' { It 'Should throw when no session is active (without -WhatIf)' { - Skip-IfMissing 'New-PveSdnSubnet' { New-PveSdnSubnet -Vnet 'myvnet' -Subnet '10.0.0.0/24' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -168,24 +57,14 @@ Describe 'New-PveSdnSubnet' { # Remove-PveSdnSubnet # --------------------------------------------------------------------------- Describe 'Remove-PveSdnSubnet' { - - BeforeAll { $script:Cmd = Get-Command 'Remove-PveSdnSubnet' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Remove-PveSdnSubnet' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Remove-PveSdnSubnet' } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { - Skip-IfMissing 'Remove-PveSdnSubnet' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High' { - Skip-IfMissing 'Remove-PveSdnSubnet' $attr = $script:Cmd.ImplementingType.GetCustomAttributes( [System.Management.Automation.CmdletAttribute], $false) | Select-Object -First 1 @@ -193,25 +72,8 @@ Describe 'Remove-PveSdnSubnet' { } } - Context 'Required parameters' { - It 'Vnet should be Mandatory' { - Skip-IfMissing 'Remove-PveSdnSubnet' - $isMandatory = $script:Cmd.Parameters['Vnet'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Subnet should be Mandatory' { - Skip-IfMissing 'Remove-PveSdnSubnet' - $isMandatory = $script:Cmd.Parameters['Subnet'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active (without -WhatIf)' { - Skip-IfMissing 'Remove-PveSdnSubnet' { Remove-PveSdnSubnet -Vnet 'myvnet' -Subnet '10.0.0.0/24' -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } diff --git a/tests/PSProxmoxVE.Tests/Nodes/NodeCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Nodes/NodeCmdlets.Tests.ps1 index 1ca0486..d51b057 100644 --- a/tests/PSProxmoxVE.Tests/Nodes/NodeCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Nodes/NodeCmdlets.Tests.ps1 @@ -13,33 +13,11 @@ BeforeAll { # Get-PveNode # --------------------------------------------------------------------------- Describe 'Get-PveNode' { - - Context 'Command existence' { - It 'Should be available after module import' { - Get-Command 'Get-PveNode' -ErrorAction SilentlyContinue | - Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - (Get-Command 'Get-PveNode').CommandType | Should -Be 'Cmdlet' - } - } - Context 'Parameter validation' { BeforeAll { $script:Cmd = Get-Command 'Get-PveNode' } - It 'Should have Name parameter' { - $script:Cmd.Parameters.ContainsKey('Name') | Should -BeTrue - } - - It 'Name should not be Mandatory' { - $p = $script:Cmd.Parameters['Name'] - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } - It 'Name should be at Position 0' { $p = $script:Cmd.Parameters['Name'] $pos = $p.ParameterSets.Values | ForEach-Object { $_.Position } @@ -50,16 +28,6 @@ Describe 'Get-PveNode' { $script:Cmd.Parameters['Name'].ParameterType | Should -Be ([string]) } - It 'Should have Session parameter (inherited from PveCmdletBase)' { - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - - It 'Session should not be Mandatory' { - $p = $script:Cmd.Parameters['Session'] - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } - It 'Should declare PveNode as OutputType' { $outputTypes = $script:Cmd.OutputType.Type $outputTypes.Name | Should -Contain 'PveNode' @@ -87,33 +55,11 @@ Describe 'Get-PveNode' { # Get-PveNodeStatus # --------------------------------------------------------------------------- Describe 'Get-PveNodeStatus' { - - Context 'Command existence' { - It 'Should be available after module import' { - Get-Command 'Get-PveNodeStatus' -ErrorAction SilentlyContinue | - Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - (Get-Command 'Get-PveNodeStatus').CommandType | Should -Be 'Cmdlet' - } - } - Context 'Parameter validation' { BeforeAll { $script:Cmd = Get-Command 'Get-PveNodeStatus' } - It 'Should have Node parameter' { - $script:Cmd.Parameters.ContainsKey('Node') | Should -BeTrue - } - - It 'Node should be Mandatory' { - $p = $script:Cmd.Parameters['Node'] - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Node should be at Position 0' { $p = $script:Cmd.Parameters['Node'] $pos = $p.ParameterSets.Values | ForEach-Object { $_.Position } @@ -131,16 +77,6 @@ Describe 'Get-PveNodeStatus' { $acceptsByPropName | Should -Not -BeNullOrEmpty } - It 'Should have Session parameter (inherited from PveCmdletBase)' { - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - - It 'Session should not be Mandatory' { - $p = $script:Cmd.Parameters['Session'] - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } - It 'Should declare PveNodeStatus as OutputType' { $outputTypes = $script:Cmd.OutputType.Type $outputTypes.Name | Should -Contain 'PveNodeStatus' diff --git a/tests/PSProxmoxVE.Tests/Nodes/NodeOpsCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Nodes/NodeOpsCmdlets.Tests.ps1 index 50024f1..16fbe27 100644 --- a/tests/PSProxmoxVE.Tests/Nodes/NodeOpsCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Nodes/NodeOpsCmdlets.Tests.ps1 @@ -6,57 +6,20 @@ Start-PveNodeVms, Stop-PveNodeVms. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:Availability = @{} - foreach ($name in @( - 'Get-PveNodeConfig', 'Set-PveNodeConfig', 'Get-PveNodeDns', 'Set-PveNodeDns', - 'Start-PveNodeVms', 'Stop-PveNodeVms' - )) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } } # --------------------------------------------------------------------------- # Get-PveNodeConfig # --------------------------------------------------------------------------- Describe 'Get-PveNodeConfig' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveNodeConfig' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveNodeConfig' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveNodeConfig' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Get-PveNodeConfig' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveNodeConfig' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveNodeConfig' { Get-PveNodeConfig -Node 'pve' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -67,39 +30,16 @@ Describe 'Get-PveNodeConfig' -Tag 'Unit' { # Set-PveNodeConfig # --------------------------------------------------------------------------- Describe 'Set-PveNodeConfig' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Set-PveNodeConfig' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Set-PveNodeConfig' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Set-PveNodeConfig' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Set-PveNodeConfig' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Set-PveNodeConfig' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Set-PveNodeConfig' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Set-PveNodeConfig' { Set-PveNodeConfig -Node 'pve' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -110,32 +50,10 @@ Describe 'Set-PveNodeConfig' -Tag 'Unit' { # Get-PveNodeDns # --------------------------------------------------------------------------- Describe 'Get-PveNodeDns' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveNodeDns' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveNodeDns' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveNodeDns' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Get-PveNodeDns' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveNodeDns' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveNodeDns' { Get-PveNodeDns -Node 'pve' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -146,45 +64,16 @@ Describe 'Get-PveNodeDns' -Tag 'Unit' { # Set-PveNodeDns # --------------------------------------------------------------------------- Describe 'Set-PveNodeDns' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Set-PveNodeDns' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Set-PveNodeDns' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Set-PveNodeDns' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Set-PveNodeDns' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Set-PveNodeDns' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Set-PveNodeDns' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Search should be Mandatory' { - Skip-IfMissing 'Set-PveNodeDns' - $isMandatory = $script:Cmd.Parameters['Search'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Set-PveNodeDns' { Set-PveNodeDns -Node 'pve' -Search 'example.com' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -195,39 +84,16 @@ Describe 'Set-PveNodeDns' -Tag 'Unit' { # Start-PveNodeVms # --------------------------------------------------------------------------- Describe 'Start-PveNodeVms' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Start-PveNodeVms' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Start-PveNodeVms' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Start-PveNodeVms' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Start-PveNodeVms' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Start-PveNodeVms' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Start-PveNodeVms' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Start-PveNodeVms' { Start-PveNodeVms -Node 'pve' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -238,23 +104,13 @@ Describe 'Start-PveNodeVms' -Tag 'Unit' { # Stop-PveNodeVms # --------------------------------------------------------------------------- Describe 'Stop-PveNodeVms' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Stop-PveNodeVms' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Stop-PveNodeVms' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Stop-PveNodeVms' } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { - Skip-IfMissing 'Stop-PveNodeVms' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High' { - Skip-IfMissing 'Stop-PveNodeVms' $attr = $script:Cmd.ImplementingType.GetCustomAttributes( [System.Management.Automation.CmdletAttribute], $false) | Select-Object -First 1 @@ -262,18 +118,8 @@ Describe 'Stop-PveNodeVms' -Tag 'Unit' { } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Stop-PveNodeVms' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Stop-PveNodeVms' { Stop-PveNodeVms -Node 'pve' -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } diff --git a/tests/PSProxmoxVE.Tests/Pools/PoolCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Pools/PoolCmdlets.Tests.ps1 index 3657ee7..eff5982 100644 --- a/tests/PSProxmoxVE.Tests/Pools/PoolCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Pools/PoolCmdlets.Tests.ps1 @@ -5,52 +5,20 @@ Get-PvePool, New-PvePool, Set-PvePool, Remove-PvePool. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:Availability = @{} - foreach ($name in @('Get-PvePool', 'New-PvePool', 'Set-PvePool', 'Remove-PvePool')) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } } # --------------------------------------------------------------------------- # Get-PvePool # --------------------------------------------------------------------------- Describe 'Get-PvePool' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PvePool' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PvePool' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PvePool' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Parameter metadata' { - It 'Should have optional PoolId parameter' { - Skip-IfMissing 'Get-PvePool' - $script:Cmd.Parameters.ContainsKey('PoolId') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PvePool' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PvePool' { Get-PvePool -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -61,35 +29,16 @@ Describe 'Get-PvePool' -Tag 'Unit' { # New-PvePool # --------------------------------------------------------------------------- Describe 'New-PvePool' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'New-PvePool' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PvePool' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'New-PvePool' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'New-PvePool' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'PoolId should be Mandatory' { - Skip-IfMissing 'New-PvePool' - $isMandatory = $script:Cmd.Parameters['PoolId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'New-PvePool' { New-PvePool -PoolId 'testpool' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -100,35 +49,16 @@ Describe 'New-PvePool' -Tag 'Unit' { # Set-PvePool # --------------------------------------------------------------------------- Describe 'Set-PvePool' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Set-PvePool' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Set-PvePool' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Set-PvePool' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Set-PvePool' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'PoolId should be Mandatory' { - Skip-IfMissing 'Set-PvePool' - $isMandatory = $script:Cmd.Parameters['PoolId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Set-PvePool' { Set-PvePool -PoolId 'testpool' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -139,23 +69,13 @@ Describe 'Set-PvePool' -Tag 'Unit' { # Remove-PvePool # --------------------------------------------------------------------------- Describe 'Remove-PvePool' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Remove-PvePool' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Remove-PvePool' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Remove-PvePool' } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { - Skip-IfMissing 'Remove-PvePool' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High' { - Skip-IfMissing 'Remove-PvePool' $attr = $script:Cmd.ImplementingType.GetCustomAttributes( [System.Management.Automation.CmdletAttribute], $false) | Select-Object -First 1 @@ -163,18 +83,8 @@ Describe 'Remove-PvePool' -Tag 'Unit' { } } - Context 'Required parameters' { - It 'PoolId should be Mandatory' { - Skip-IfMissing 'Remove-PvePool' - $isMandatory = $script:Cmd.Parameters['PoolId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Remove-PvePool' { Remove-PvePool -PoolId 'testpool' -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } diff --git a/tests/PSProxmoxVE.Tests/Snapshots/SnapshotCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Snapshots/SnapshotCmdlets.Tests.ps1 index c83b8f7..1c83108 100644 --- a/tests/PSProxmoxVE.Tests/Snapshots/SnapshotCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Snapshots/SnapshotCmdlets.Tests.ps1 @@ -5,7 +5,6 @@ Get-PveSnapshot, New-PveSnapshot, Remove-PveSnapshot, Restore-PveSnapshot. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. Snapshot cmdlets apply to both QEMU VMs and LXC containers; the parameter set distinction is captured in the 'Type' tests below. @@ -13,88 +12,16 @@ BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:Availability = @{} - foreach ($name in @('Get-PveSnapshot', 'New-PveSnapshot', - 'Remove-PveSnapshot', 'Restore-PveSnapshot')) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } -} - -# --------------------------------------------------------------------------- -# Manifest contract -# --------------------------------------------------------------------------- -Describe 'Snapshot cmdlets — manifest declarations' { - BeforeAll { - $manifestPath = Join-Path (Get-Module PSProxmoxVE).ModuleBase 'PSProxmoxVE.psd1' - $script:Manifest = if (Test-Path $manifestPath) { Import-PowerShellDataFile $manifestPath } else { $null } - } - - It " should be declared in CmdletsToExport" -TestCases @( - @{ cmdName = 'Get-PveSnapshot' } - @{ cmdName = 'New-PveSnapshot' } - @{ cmdName = 'Remove-PveSnapshot' } - @{ cmdName = 'Restore-PveSnapshot' } - ) { - if ($null -eq $script:Manifest) { Set-ItResult -Skipped -Because 'Manifest not found'; return } - $script:Manifest.CmdletsToExport | Should -Contain $cmdName - } } # --------------------------------------------------------------------------- # Get-PveSnapshot # --------------------------------------------------------------------------- Describe 'Get-PveSnapshot' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveSnapshot' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveSnapshot' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveSnapshot' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Parameter metadata' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Get-PveSnapshot' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'VmId should be Mandatory' { - Skip-IfMissing 'Get-PveSnapshot' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Should have Name parameter (optional filter by snapshot name)' { - Skip-IfMissing 'Get-PveSnapshot' - $script:Cmd.Parameters.ContainsKey('Name') | Should -BeTrue - } - - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveSnapshot' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveSnapshot' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveSnapshot' { Get-PveSnapshot -Node 'pve-node1' -VmId 100 -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -105,66 +32,16 @@ Describe 'Get-PveSnapshot' { # New-PveSnapshot # --------------------------------------------------------------------------- Describe 'New-PveSnapshot' { - - BeforeAll { $script:Cmd = Get-Command 'New-PveSnapshot' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PveSnapshot' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'New-PveSnapshot' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'New-PveSnapshot' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'New-PveSnapshot' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'VmId should be Mandatory' { - Skip-IfMissing 'New-PveSnapshot' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Name (snapshot name) should be Mandatory' { - Skip-IfMissing 'New-PveSnapshot' - $isMandatory = $script:Cmd.Parameters['Name'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - - Context 'Optional parameters' { - It 'Should have Description parameter' { - Skip-IfMissing 'New-PveSnapshot' - $script:Cmd.Parameters.ContainsKey('Description') | Should -BeTrue - } - - It 'Should have IncludeVmState switch parameter' { - Skip-IfMissing 'New-PveSnapshot' - $script:Cmd.Parameters.ContainsKey('IncludeVmState') | Should -BeTrue - } - - It 'Should have Wait switch parameter' { - Skip-IfMissing 'New-PveSnapshot' - $script:Cmd.Parameters.ContainsKey('Wait') | Should -BeTrue - } - } - Context 'Without active session' { It 'Should throw when no session is active (without -WhatIf)' { - Skip-IfMissing 'New-PveSnapshot' { New-PveSnapshot -Node 'pve-node1' -VmId 100 -Name 'snap1' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -175,24 +52,14 @@ Describe 'New-PveSnapshot' { # Remove-PveSnapshot # --------------------------------------------------------------------------- Describe 'Remove-PveSnapshot' { - - BeforeAll { $script:Cmd = Get-Command 'Remove-PveSnapshot' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Remove-PveSnapshot' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Remove-PveSnapshot' } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { - Skip-IfMissing 'Remove-PveSnapshot' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High' { - Skip-IfMissing 'Remove-PveSnapshot' $attr = $script:Cmd.ImplementingType.GetCustomAttributes( [System.Management.Automation.CmdletAttribute], $false) | Select-Object -First 1 @@ -200,32 +67,8 @@ Describe 'Remove-PveSnapshot' { } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Remove-PveSnapshot' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'VmId should be Mandatory' { - Skip-IfMissing 'Remove-PveSnapshot' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Name should be Mandatory' { - Skip-IfMissing 'Remove-PveSnapshot' - $isMandatory = $script:Cmd.Parameters['Name'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active (without -WhatIf)' { - Skip-IfMissing 'Remove-PveSnapshot' { Remove-PveSnapshot -Node 'pve-node1' -VmId 100 -Name 'snap1' -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -236,24 +79,14 @@ Describe 'Remove-PveSnapshot' { # Restore-PveSnapshot # --------------------------------------------------------------------------- Describe 'Restore-PveSnapshot' { - - BeforeAll { $script:Cmd = Get-Command 'Restore-PveSnapshot' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Restore-PveSnapshot' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Restore-PveSnapshot' } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { - Skip-IfMissing 'Restore-PveSnapshot' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High' { - Skip-IfMissing 'Restore-PveSnapshot' $attr = $script:Cmd.ImplementingType.GetCustomAttributes( [System.Management.Automation.CmdletAttribute], $false) | Select-Object -First 1 @@ -261,39 +94,8 @@ Describe 'Restore-PveSnapshot' { } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Restore-PveSnapshot' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'VmId should be Mandatory' { - Skip-IfMissing 'Restore-PveSnapshot' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Name should be Mandatory' { - Skip-IfMissing 'Restore-PveSnapshot' - $isMandatory = $script:Cmd.Parameters['Name'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - - Context 'Optional parameters' { - It 'Should have Wait switch parameter' { - Skip-IfMissing 'Restore-PveSnapshot' - $script:Cmd.Parameters.ContainsKey('Wait') | Should -BeTrue - } - } - Context 'Without active session' { It 'Should throw when no session is active (without -WhatIf)' { - Skip-IfMissing 'Restore-PveSnapshot' { Restore-PveSnapshot -Node 'pve-node1' -VmId 100 -Name 'snap1' -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } diff --git a/tests/PSProxmoxVE.Tests/Storage/Get-PveStorage.Tests.ps1 b/tests/PSProxmoxVE.Tests/Storage/Get-PveStorage.Tests.ps1 index e66f721..580ea8d 100644 --- a/tests/PSProxmoxVE.Tests/Storage/Get-PveStorage.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Storage/Get-PveStorage.Tests.ps1 @@ -5,90 +5,20 @@ Get-PveStorage, Get-PveStorageContent, New-PveStorage, Remove-PveStorage. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:Availability = @{} - foreach ($name in @('Get-PveStorage', 'Get-PveStorageContent', - 'New-PveStorage', 'Remove-PveStorage')) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } -} - -# --------------------------------------------------------------------------- -# Manifest contract -# --------------------------------------------------------------------------- -Describe 'Storage cmdlets — manifest declarations' { - It 'Get-PveStorage should be declared in CmdletsToExport' { - $manifestPath = Join-Path (Get-Module PSProxmoxVE).ModuleBase 'PSProxmoxVE.psd1' - if (-not (Test-Path $manifestPath)) { Set-ItResult -Skipped -Because 'Manifest not found'; return } - $manifest = Import-PowerShellDataFile $manifestPath - $manifest.CmdletsToExport | Should -Contain 'Get-PveStorage' - } - - It 'Get-PveStorageContent should be declared in CmdletsToExport' { - $manifestPath = Join-Path (Get-Module PSProxmoxVE).ModuleBase 'PSProxmoxVE.psd1' - if (-not (Test-Path $manifestPath)) { Set-ItResult -Skipped -Because 'Manifest not found'; return } - $manifest = Import-PowerShellDataFile $manifestPath - $manifest.CmdletsToExport | Should -Contain 'Get-PveStorageContent' - } } # --------------------------------------------------------------------------- # Get-PveStorage # --------------------------------------------------------------------------- Describe 'Get-PveStorage' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveStorage' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveStorage' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveStorage' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Parameter metadata' { - It 'Should have Node parameter' { - Skip-IfMissing 'Get-PveStorage' - $script:Cmd.Parameters.ContainsKey('Node') | Should -BeTrue - } - - It 'Node should not be Mandatory (cluster-wide query when omitted)' { - Skip-IfMissing 'Get-PveStorage' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } - - It 'Should have Storage parameter (filter by name)' { - Skip-IfMissing 'Get-PveStorage' - $script:Cmd.Parameters.ContainsKey('Storage') | Should -BeTrue - } - - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveStorage' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveStorage' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveStorage' { Get-PveStorage -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -99,36 +29,10 @@ Describe 'Get-PveStorage' { # Get-PveStorageContent # --------------------------------------------------------------------------- Describe 'Get-PveStorageContent' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveStorageContent' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveStorageContent' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } - - Context 'Parameter metadata' { - It 'Node should be present' { - Skip-IfMissing 'Get-PveStorageContent' - $script:Cmd.Parameters.ContainsKey('Node') | Should -BeTrue - } - - It 'Storage should be present' { - Skip-IfMissing 'Get-PveStorageContent' - $script:Cmd.Parameters.ContainsKey('Storage') | Should -BeTrue - } - - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveStorageContent' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveStorageContent' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveStorageContent' { Get-PveStorageContent -Node 'pve-node1' -Storage 'local' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -139,76 +43,16 @@ Describe 'Get-PveStorageContent' { # New-PveStorage # --------------------------------------------------------------------------- Describe 'New-PveStorage' { - - BeforeAll { $script:Cmd = Get-Command 'New-PveStorage' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PveStorage' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'New-PveStorage' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'New-PveStorage' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Storage (name) should be Mandatory' { - Skip-IfMissing 'New-PveStorage' - $isMandatory = $script:Cmd.Parameters['Storage'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Type should be Mandatory' { - Skip-IfMissing 'New-PveStorage' - $isMandatory = $script:Cmd.Parameters['Type'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'iSCSI/NFS parameters' { - It 'Should have Target parameter for iSCSI IQN' { - Skip-IfMissing 'New-PveStorage' - $script:Cmd.Parameters.ContainsKey('Target') | Should -BeTrue - } - - It 'Target should not be Mandatory' { - Skip-IfMissing 'New-PveStorage' - $isMandatory = $script:Cmd.Parameters['Target'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } - - It 'Should have Portal parameter for iSCSI portal' { - Skip-IfMissing 'New-PveStorage' - $script:Cmd.Parameters.ContainsKey('Portal') | Should -BeTrue - } - - It 'Portal should not be Mandatory' { - Skip-IfMissing 'New-PveStorage' - $isMandatory = $script:Cmd.Parameters['Portal'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } - - It 'Should have Server parameter for NFS/iSCSI server' { - Skip-IfMissing 'New-PveStorage' - $script:Cmd.Parameters.ContainsKey('Server') | Should -BeTrue - } - - It 'Should have Export parameter for NFS export path' { - Skip-IfMissing 'New-PveStorage' - $script:Cmd.Parameters.ContainsKey('Export') | Should -BeTrue - } - It 'Should have Shared switch parameter' { - Skip-IfMissing 'New-PveStorage' $script:Cmd.Parameters.ContainsKey('Shared') | Should -BeTrue $script:Cmd.Parameters['Shared'].ParameterType | Should -Be ([System.Management.Automation.SwitchParameter]) } @@ -219,37 +63,18 @@ Describe 'New-PveStorage' { # Remove-PveStorage # --------------------------------------------------------------------------- Describe 'Remove-PveStorage' { - - BeforeAll { $script:Cmd = Get-Command 'Remove-PveStorage' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Remove-PveStorage' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Remove-PveStorage' } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { - Skip-IfMissing 'Remove-PveStorage' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High' { - Skip-IfMissing 'Remove-PveStorage' $attr = $script:Cmd.ImplementingType.GetCustomAttributes( [System.Management.Automation.CmdletAttribute], $false) | Select-Object -First 1 $attr.ConfirmImpact | Should -Be ([System.Management.Automation.ConfirmImpact]::High) } } - - Context 'Required parameters' { - It 'Storage should be Mandatory' { - Skip-IfMissing 'Remove-PveStorage' - $isMandatory = $script:Cmd.Parameters['Storage'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } } diff --git a/tests/PSProxmoxVE.Tests/Storage/Send-PveFile.Tests.ps1 b/tests/PSProxmoxVE.Tests/Storage/Send-PveFile.Tests.ps1 index d729ca2..d9366bf 100644 --- a/tests/PSProxmoxVE.Tests/Storage/Send-PveFile.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Storage/Send-PveFile.Tests.ps1 @@ -3,80 +3,25 @@ .SYNOPSIS Pester 5 tests for Send-PveFile. All tests are fully offline — no live Proxmox VE target is required. - If the cmdlet is not yet compiled the tests are marked Skipped. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:CmdExists = $null -ne (Get-Command 'Send-PveFile' -ErrorAction SilentlyContinue) } Describe 'Send-PveFile' { - - Context 'Manifest declaration' { - It 'Should be declared in CmdletsToExport' { - $manifestPath = Join-Path (Get-Module PSProxmoxVE).ModuleBase 'PSProxmoxVE.psd1' - if (-not (Test-Path $manifestPath)) { Set-ItResult -Skipped -Because 'Manifest not found'; return } - $manifest = Import-PowerShellDataFile $manifestPath - $manifest.CmdletsToExport | Should -Contain 'Send-PveFile' - } - } - - Context 'Command existence' { - It 'Should be available after module import' { - if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return } - (Get-Command 'Send-PveFile').CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Required parameters' { - BeforeAll { - $script:Cmd = Get-Command 'Send-PveFile' -ErrorAction SilentlyContinue - } - - It 'Should have Node parameter (Mandatory)' { - if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return } - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Should have Storage parameter (Mandatory)' { - if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return } - $isMandatory = $script:Cmd.Parameters['Storage'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Should have Path parameter (Mandatory)' { - if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return } - $isMandatory = $script:Cmd.Parameters['Path'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - } - Context 'ChecksumAlgorithm ValidateSet' { BeforeAll { - $script:Cmd = Get-Command 'Send-PveFile' -ErrorAction SilentlyContinue - } - - It 'Should have ChecksumAlgorithm parameter' { - if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return } - $script:Cmd.Parameters.ContainsKey('ChecksumAlgorithm') | Should -BeTrue + $script:Cmd = Get-Command 'Send-PveFile' } It 'ChecksumAlgorithm should have a ValidateSet attribute' { - if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return } $validateSetAttr = $script:Cmd.Parameters['ChecksumAlgorithm'].Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } $validateSetAttr | Should -Not -BeNullOrEmpty } It 'ChecksumAlgorithm ValidateSet should include md5' { - if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return } $validateSetAttr = $script:Cmd.Parameters['ChecksumAlgorithm'].Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } | Select-Object -First 1 @@ -84,7 +29,6 @@ Describe 'Send-PveFile' { } It 'ChecksumAlgorithm ValidateSet should include sha1' { - if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return } $validateSetAttr = $script:Cmd.Parameters['ChecksumAlgorithm'].Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } | Select-Object -First 1 @@ -92,7 +36,6 @@ Describe 'Send-PveFile' { } It 'ChecksumAlgorithm ValidateSet should include sha256' { - if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return } $validateSetAttr = $script:Cmd.Parameters['ChecksumAlgorithm'].Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } | Select-Object -First 1 @@ -100,7 +43,6 @@ Describe 'Send-PveFile' { } It 'ChecksumAlgorithm ValidateSet should include sha512' { - if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return } $validateSetAttr = $script:Cmd.Parameters['ChecksumAlgorithm'].Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } | Select-Object -First 1 @@ -110,16 +52,10 @@ Describe 'Send-PveFile' { Context 'ContentType parameter' { BeforeAll { - $script:Cmd = Get-Command 'Send-PveFile' -ErrorAction SilentlyContinue - } - - It 'Should have ContentType parameter' { - if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return } - $script:Cmd.Parameters.ContainsKey('ContentType') | Should -BeTrue + $script:Cmd = Get-Command 'Send-PveFile' } It 'ContentType should have a ValidateSet attribute with iso, vztmpl, import' { - if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return } $validateSetAttr = $script:Cmd.Parameters['ContentType'].Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } | Select-Object -First 1 @@ -131,37 +67,20 @@ Describe 'Send-PveFile' { Context 'ShouldProcess support' { BeforeAll { - $script:Cmd = Get-Command 'Send-PveFile' -ErrorAction SilentlyContinue + $script:Cmd = Get-Command 'Send-PveFile' } It 'Should support WhatIf' { - if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return } $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } Context 'Optional parameters' { BeforeAll { - $script:Cmd = Get-Command 'Send-PveFile' -ErrorAction SilentlyContinue - } - - It 'Should have Checksum parameter' { - if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return } - $script:Cmd.Parameters.ContainsKey('Checksum') | Should -BeTrue - } - - It 'Should have Session parameter' { - if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return } - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - - It 'Should have TimeoutSeconds parameter' { - if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return } - $script:Cmd.Parameters.ContainsKey('TimeoutSeconds') | Should -BeTrue + $script:Cmd = Get-Command 'Send-PveFile' } It 'TimeoutSeconds should reject negative values' { - if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return } $tmpIso = [System.IO.Path]::GetTempFileName() try { { Send-PveFile -Node 'n' -Storage 's' -Path $tmpIso -TimeoutSeconds -1 -Confirm:$false -ErrorAction Stop } | @@ -172,7 +91,6 @@ Describe 'Send-PveFile' { Context 'Without active session' { It 'Should throw when no session is active (without -WhatIf)' { - if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return } $tmpIso = [System.IO.Path]::GetTempFileName() try { { Send-PveFile -Node 'pve-node1' -Storage 'local' -Path $tmpIso -Confirm:$false -ErrorAction Stop } | diff --git a/tests/PSProxmoxVE.Tests/Storage/SetPveStorageCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Storage/SetPveStorageCmdlets.Tests.ps1 index 11b0deb..35d0e97 100644 --- a/tests/PSProxmoxVE.Tests/Storage/SetPveStorageCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Storage/SetPveStorageCmdlets.Tests.ps1 @@ -6,64 +6,26 @@ Set-PveStorageContent, New-PveStorageDisk. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:Availability = @{} - foreach ($name in @( - 'Set-PveStorage', 'Get-PveStorageStatus', 'Remove-PveStorageContent', - 'Set-PveStorageContent', 'New-PveStorageDisk' - )) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } } # --------------------------------------------------------------------------- # Set-PveStorage # --------------------------------------------------------------------------- Describe 'Set-PveStorage' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Set-PveStorage' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Set-PveStorage' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Set-PveStorage' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Set-PveStorage' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Set-PveStorage' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Storage should be Mandatory' { - Skip-IfMissing 'Set-PveStorage' - $isMandatory = $script:Cmd.Parameters['Storage'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Set-PveStorage' { Set-PveStorage -Storage 'local' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -74,38 +36,10 @@ Describe 'Set-PveStorage' -Tag 'Unit' { # Get-PveStorageStatus # --------------------------------------------------------------------------- Describe 'Get-PveStorageStatus' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveStorageStatus' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveStorageStatus' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveStorageStatus' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Get-PveStorageStatus' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Storage should be Mandatory' { - Skip-IfMissing 'Get-PveStorageStatus' - $isMandatory = $script:Cmd.Parameters['Storage'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveStorageStatus' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveStorageStatus' { Get-PveStorageStatus -Node 'pve' -Storage 'local' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -116,23 +50,13 @@ Describe 'Get-PveStorageStatus' -Tag 'Unit' { # Remove-PveStorageContent # --------------------------------------------------------------------------- Describe 'Remove-PveStorageContent' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Remove-PveStorageContent' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Remove-PveStorageContent' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Remove-PveStorageContent' } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { - Skip-IfMissing 'Remove-PveStorageContent' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High' { - Skip-IfMissing 'Remove-PveStorageContent' $attr = $script:Cmd.ImplementingType.GetCustomAttributes( [System.Management.Automation.CmdletAttribute], $false) | Select-Object -First 1 @@ -140,30 +64,8 @@ Describe 'Remove-PveStorageContent' -Tag 'Unit' { } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Remove-PveStorageContent' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Storage should be Mandatory' { - Skip-IfMissing 'Remove-PveStorageContent' - $isMandatory = $script:Cmd.Parameters['Storage'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Volume should be Mandatory' { - Skip-IfMissing 'Remove-PveStorageContent' - $isMandatory = $script:Cmd.Parameters['Volume'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Remove-PveStorageContent' { Remove-PveStorageContent -Node 'pve' -Storage 'local' -Volume 'local:iso/test.iso' -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -174,51 +76,16 @@ Describe 'Remove-PveStorageContent' -Tag 'Unit' { # Set-PveStorageContent # --------------------------------------------------------------------------- Describe 'Set-PveStorageContent' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Set-PveStorageContent' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Set-PveStorageContent' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Set-PveStorageContent' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Set-PveStorageContent' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Set-PveStorageContent' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Set-PveStorageContent' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Storage should be Mandatory' { - Skip-IfMissing 'Set-PveStorageContent' - $isMandatory = $script:Cmd.Parameters['Storage'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Volume should be Mandatory' { - Skip-IfMissing 'Set-PveStorageContent' - $isMandatory = $script:Cmd.Parameters['Volume'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Set-PveStorageContent' { Set-PveStorageContent -Node 'pve' -Storage 'local' -Volume 'local:iso/test.iso' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -229,57 +96,16 @@ Describe 'Set-PveStorageContent' -Tag 'Unit' { # New-PveStorageDisk # --------------------------------------------------------------------------- Describe 'New-PveStorageDisk' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'New-PveStorageDisk' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PveStorageDisk' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'New-PveStorageDisk' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'New-PveStorageDisk' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'New-PveStorageDisk' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'New-PveStorageDisk' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Storage should be Mandatory' { - Skip-IfMissing 'New-PveStorageDisk' - $isMandatory = $script:Cmd.Parameters['Storage'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Filename should be Mandatory' { - Skip-IfMissing 'New-PveStorageDisk' - $isMandatory = $script:Cmd.Parameters['Filename'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Size should be Mandatory' { - Skip-IfMissing 'New-PveStorageDisk' - $isMandatory = $script:Cmd.Parameters['Size'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'New-PveStorageDisk' { New-PveStorageDisk -Node 'pve' -Storage 'local' -Filename 'vm-100-disk-1' -Size '32G' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } diff --git a/tests/PSProxmoxVE.Tests/Storage/StorageDownload.Tests.ps1 b/tests/PSProxmoxVE.Tests/Storage/StorageDownload.Tests.ps1 index 4d17b59..d88ed91 100644 --- a/tests/PSProxmoxVE.Tests/Storage/StorageDownload.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Storage/StorageDownload.Tests.ps1 @@ -4,116 +4,48 @@ Pester 5 tests for Invoke-PveStorageDownload. All tests are fully offline — no live Proxmox VE target is required. - If the cmdlet is not yet compiled the test is marked Skipped. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:CmdExists = $null -ne (Get-Command 'Invoke-PveStorageDownload' -ErrorAction SilentlyContinue) - - function Skip-IfMissing([string]$Name) { - if (-not $script:CmdExists) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } -} - -# --------------------------------------------------------------------------- -# Manifest contract -# --------------------------------------------------------------------------- -Describe 'Invoke-PveStorageDownload — manifest declaration' { - It 'Should be declared in CmdletsToExport' { - $manifestPath = Join-Path (Get-Module PSProxmoxVE).ModuleBase 'PSProxmoxVE.psd1' - if (-not (Test-Path $manifestPath)) { Set-ItResult -Skipped -Because 'Manifest not found'; return } - $manifest = Import-PowerShellDataFile $manifestPath - $manifest.CmdletsToExport | Should -Contain 'Invoke-PveStorageDownload' - } } # --------------------------------------------------------------------------- # Invoke-PveStorageDownload # --------------------------------------------------------------------------- Describe 'Invoke-PveStorageDownload' { - - BeforeAll { $script:Cmd = Get-Command 'Invoke-PveStorageDownload' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Invoke-PveStorageDownload' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Invoke-PveStorageDownload' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Invoke-PveStorageDownload' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Invoke-PveStorageDownload' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should support Confirm' { - Skip-IfMissing 'Invoke-PveStorageDownload' $script:Cmd.Parameters.ContainsKey('Confirm') | Should -BeTrue } } Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Invoke-PveStorageDownload' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Node should be at Position 0' { - Skip-IfMissing 'Invoke-PveStorageDownload' $pos = $script:Cmd.Parameters['Node'].ParameterSets.Values | ForEach-Object { $_.Position } $pos | Should -Contain 0 } - It 'Storage should be Mandatory' { - Skip-IfMissing 'Invoke-PveStorageDownload' - $isMandatory = $script:Cmd.Parameters['Storage'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Storage should be at Position 1' { - Skip-IfMissing 'Invoke-PveStorageDownload' $pos = $script:Cmd.Parameters['Storage'].ParameterSets.Values | ForEach-Object { $_.Position } $pos | Should -Contain 1 } - It 'Url should be Mandatory' { - Skip-IfMissing 'Invoke-PveStorageDownload' - $isMandatory = $script:Cmd.Parameters['Url'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Url should be at Position 2' { - Skip-IfMissing 'Invoke-PveStorageDownload' $pos = $script:Cmd.Parameters['Url'].ParameterSets.Values | ForEach-Object { $_.Position } $pos | Should -Contain 2 } - It 'Filename should be Mandatory' { - Skip-IfMissing 'Invoke-PveStorageDownload' - $isMandatory = $script:Cmd.Parameters['Filename'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Filename should be at Position 3' { - Skip-IfMissing 'Invoke-PveStorageDownload' $pos = $script:Cmd.Parameters['Filename'].ParameterSets.Values | ForEach-Object { $_.Position } $pos | Should -Contain 3 @@ -121,20 +53,7 @@ Describe 'Invoke-PveStorageDownload' { } Context 'Optional parameters' { - It 'Should have ContentType parameter' { - Skip-IfMissing 'Invoke-PveStorageDownload' - $script:Cmd.Parameters.ContainsKey('ContentType') | Should -BeTrue - } - - It 'ContentType should not be Mandatory' { - Skip-IfMissing 'Invoke-PveStorageDownload' - $isMandatory = $script:Cmd.Parameters['ContentType'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } - It 'ContentType should have a ValidateSet of iso, vztmpl, backup, import' { - Skip-IfMissing 'Invoke-PveStorageDownload' $validateSet = $script:Cmd.Parameters['ContentType'].Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } $validateSet | Should -Not -BeNullOrEmpty @@ -146,33 +65,18 @@ Describe 'Invoke-PveStorageDownload' { } It 'Should have Wait switch parameter' { - Skip-IfMissing 'Invoke-PveStorageDownload' $script:Cmd.Parameters.ContainsKey('Wait') | Should -BeTrue $script:Cmd.Parameters['Wait'].SwitchParameter | Should -BeTrue } - It 'Should have TimeoutSeconds parameter' { - Skip-IfMissing 'Invoke-PveStorageDownload' - $script:Cmd.Parameters.ContainsKey('TimeoutSeconds') | Should -BeTrue - } - It 'TimeoutSeconds should reject negative values' { - Skip-IfMissing 'Invoke-PveStorageDownload' { Invoke-PveStorageDownload -Node 'pve1' -Storage 'local' -Url 'https://example.com/test.iso' -Filename 'test.iso' -TimeoutSeconds -1 -Confirm:$false -ErrorAction Stop } | Should -Throw } } - Context 'Session parameter' { - It 'Should have Session parameter (inherited from PveCmdletBase)' { - Skip-IfMissing 'Invoke-PveStorageDownload' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Invoke-PveStorageDownload' { Invoke-PveStorageDownload -Node 'pve1' -Storage 'local' -Url 'https://example.com/test.iso' -Filename 'test.iso' -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } diff --git a/tests/PSProxmoxVE.Tests/Tasks/TaskCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Tasks/TaskCmdlets.Tests.ps1 index 710d5f6..b266628 100644 --- a/tests/PSProxmoxVE.Tests/Tasks/TaskCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Tasks/TaskCmdlets.Tests.ps1 @@ -13,33 +13,11 @@ BeforeAll { # Get-PveTask # --------------------------------------------------------------------------- Describe 'Get-PveTask' { - - Context 'Command existence' { - It 'Should be available after module import' { - Get-Command 'Get-PveTask' -ErrorAction SilentlyContinue | - Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - (Get-Command 'Get-PveTask').CommandType | Should -Be 'Cmdlet' - } - } - Context 'Parameter validation' { BeforeAll { $script:Cmd = Get-Command 'Get-PveTask' } - It 'Should have Node parameter' { - $script:Cmd.Parameters.ContainsKey('Node') | Should -BeTrue - } - - It 'Node should be Mandatory' { - $p = $script:Cmd.Parameters['Node'] - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Node should be at Position 0' { $p = $script:Cmd.Parameters['Node'] $pos = $p.ParameterSets.Values | ForEach-Object { $_.Position } @@ -50,16 +28,6 @@ Describe 'Get-PveTask' { $script:Cmd.Parameters['Node'].ParameterType | Should -Be ([string]) } - It 'Should have Upid parameter' { - $script:Cmd.Parameters.ContainsKey('Upid') | Should -BeTrue - } - - It 'Upid should be Mandatory' { - $p = $script:Cmd.Parameters['Upid'] - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Upid should be at Position 1' { $p = $script:Cmd.Parameters['Upid'] $pos = $p.ParameterSets.Values | ForEach-Object { $_.Position } @@ -77,16 +45,6 @@ Describe 'Get-PveTask' { $acceptsByPropName | Should -Not -BeNullOrEmpty } - It 'Should have Session parameter (inherited from PveCmdletBase)' { - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - - It 'Session should not be Mandatory' { - $p = $script:Cmd.Parameters['Session'] - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } - It 'Should declare PveTask as OutputType' { $outputTypes = $script:Cmd.OutputType.Type $outputTypes.Name | Should -Contain 'PveTask' @@ -133,33 +91,11 @@ Describe 'Get-PveTask' { # Wait-PveTask # --------------------------------------------------------------------------- Describe 'Wait-PveTask' { - - Context 'Command existence' { - It 'Should be available after module import' { - Get-Command 'Wait-PveTask' -ErrorAction SilentlyContinue | - Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - (Get-Command 'Wait-PveTask').CommandType | Should -Be 'Cmdlet' - } - } - Context 'Parameter validation' { BeforeAll { $script:Cmd = Get-Command 'Wait-PveTask' } - It 'Should have Node parameter' { - $script:Cmd.Parameters.ContainsKey('Node') | Should -BeTrue - } - - It 'Node should be Mandatory' { - $p = $script:Cmd.Parameters['Node'] - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Node should be at Position 0' { $p = $script:Cmd.Parameters['Node'] $pos = $p.ParameterSets.Values | ForEach-Object { $_.Position } @@ -170,16 +106,6 @@ Describe 'Wait-PveTask' { $script:Cmd.Parameters['Node'].ParameterType | Should -Be ([string]) } - It 'Should have Upid parameter' { - $script:Cmd.Parameters.ContainsKey('Upid') | Should -BeTrue - } - - It 'Upid should be Mandatory' { - $p = $script:Cmd.Parameters['Upid'] - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Upid should be at Position 1' { $p = $script:Cmd.Parameters['Upid'] $pos = $p.ParameterSets.Values | ForEach-Object { $_.Position } @@ -197,46 +123,16 @@ Describe 'Wait-PveTask' { $acceptsByPropName | Should -Not -BeNullOrEmpty } - It 'Should have Timeout parameter' { - $script:Cmd.Parameters.ContainsKey('Timeout') | Should -BeTrue - } - - It 'Timeout should not be Mandatory' { - $p = $script:Cmd.Parameters['Timeout'] - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } - It 'Timeout should be of type Nullable[TimeSpan]' { $script:Cmd.Parameters['Timeout'].ParameterType | Should -Be ([System.Nullable[System.TimeSpan]]) } - It 'Should have PollInterval parameter' { - $script:Cmd.Parameters.ContainsKey('PollInterval') | Should -BeTrue - } - - It 'PollInterval should not be Mandatory' { - $p = $script:Cmd.Parameters['PollInterval'] - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } - It 'PollInterval should be of type Nullable[TimeSpan]' { $script:Cmd.Parameters['PollInterval'].ParameterType | Should -Be ([System.Nullable[System.TimeSpan]]) } - It 'Should have Session parameter (inherited from PveCmdletBase)' { - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - - It 'Session should not be Mandatory' { - $p = $script:Cmd.Parameters['Session'] - $isMandatory = $p.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } - It 'Should declare PveTask as OutputType' { $outputTypes = $script:Cmd.OutputType.Type $outputTypes.Name | Should -Contain 'PveTask' diff --git a/tests/PSProxmoxVE.Tests/Tasks/TaskListCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Tasks/TaskListCmdlets.Tests.ps1 index 3aec602..f912912 100644 --- a/tests/PSProxmoxVE.Tests/Tasks/TaskListCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Tasks/TaskListCmdlets.Tests.ps1 @@ -5,65 +5,20 @@ Get-PveTaskList, Stop-PveTask. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:Availability = @{} - foreach ($name in @('Get-PveTaskList', 'Stop-PveTask')) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } } # --------------------------------------------------------------------------- # Get-PveTaskList # --------------------------------------------------------------------------- Describe 'Get-PveTaskList' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveTaskList' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveTaskList' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveTaskList' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Get-PveTaskList' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - - Context 'Parameter metadata' { - It 'Should have optional VmId parameter' { - Skip-IfMissing 'Get-PveTaskList' - $script:Cmd.Parameters.ContainsKey('VmId') | Should -BeTrue - } - It 'Should have optional Limit parameter' { - Skip-IfMissing 'Get-PveTaskList' - $script:Cmd.Parameters.ContainsKey('Limit') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveTaskList' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveTaskList' { Get-PveTaskList -Node 'pve' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -74,27 +29,13 @@ Describe 'Get-PveTaskList' -Tag 'Unit' { # Stop-PveTask # --------------------------------------------------------------------------- Describe 'Stop-PveTask' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Stop-PveTask' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Stop-PveTask' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Stop-PveTask' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Stop-PveTask' } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { - Skip-IfMissing 'Stop-PveTask' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High' { - Skip-IfMissing 'Stop-PveTask' $attr = $script:Cmd.ImplementingType.GetCustomAttributes( [System.Management.Automation.CmdletAttribute], $false) | Select-Object -First 1 @@ -102,24 +43,8 @@ Describe 'Stop-PveTask' -Tag 'Unit' { } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Stop-PveTask' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Upid should be Mandatory' { - Skip-IfMissing 'Stop-PveTask' - $isMandatory = $script:Cmd.Parameters['Upid'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Stop-PveTask' { Stop-PveTask -Node 'pve' -Upid 'UPID:pve:00000001:00000000:00000000:test::root@pam:' -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } diff --git a/tests/PSProxmoxVE.Tests/Templates/TemplateCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Templates/TemplateCmdlets.Tests.ps1 index 37b231e..8f0f041 100644 --- a/tests/PSProxmoxVE.Tests/Templates/TemplateCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Templates/TemplateCmdlets.Tests.ps1 @@ -5,7 +5,6 @@ Get-PveTemplate, New-PveTemplate, Remove-PveTemplate, New-PveVmFromTemplate. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. Note: New-PveTemplate converts an existing VM into a template (destructive — the original VM becomes read-only). New-PveVmFromTemplate deploys a new VM @@ -14,86 +13,16 @@ BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:Availability = @{} - foreach ($name in @('Get-PveTemplate', 'New-PveTemplate', - 'Remove-PveTemplate', 'New-PveVmFromTemplate')) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } -} - -# --------------------------------------------------------------------------- -# Manifest contract -# --------------------------------------------------------------------------- -Describe 'Template cmdlets — manifest declarations' { - BeforeAll { - $manifestPath = Join-Path (Get-Module PSProxmoxVE).ModuleBase 'PSProxmoxVE.psd1' - $script:Manifest = if (Test-Path $manifestPath) { Import-PowerShellDataFile $manifestPath } else { $null } - } - - It " should be declared in CmdletsToExport" -TestCases @( - @{ cmdName = 'Get-PveTemplate' } - @{ cmdName = 'New-PveTemplate' } - @{ cmdName = 'Remove-PveTemplate' } - @{ cmdName = 'New-PveVmFromTemplate' } - ) { - if ($null -eq $script:Manifest) { Set-ItResult -Skipped -Because 'Manifest not found'; return } - $script:Manifest.CmdletsToExport | Should -Contain $cmdName - } } # --------------------------------------------------------------------------- # Get-PveTemplate # --------------------------------------------------------------------------- Describe 'Get-PveTemplate' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveTemplate' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveTemplate' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveTemplate' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Parameter metadata' { - It 'Should have Node parameter (optional — all nodes when omitted)' { - Skip-IfMissing 'Get-PveTemplate' - $script:Cmd.Parameters.ContainsKey('Node') | Should -BeTrue - } - - It 'Node should not be Mandatory' { - Skip-IfMissing 'Get-PveTemplate' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } - - It 'Should have Name parameter (optional filter by template name)' { - Skip-IfMissing 'Get-PveTemplate' - $script:Cmd.Parameters.ContainsKey('Name') | Should -BeTrue - } - - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveTemplate' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveTemplate' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveTemplate' { Get-PveTemplate -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -104,24 +33,14 @@ Describe 'Get-PveTemplate' { # New-PveTemplate (converts an existing VM to a template) # --------------------------------------------------------------------------- Describe 'New-PveTemplate' { - - BeforeAll { $script:Cmd = Get-Command 'New-PveTemplate' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PveTemplate' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'New-PveTemplate' } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { - Skip-IfMissing 'New-PveTemplate' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High (destructive — VM becomes read-only template)' { - Skip-IfMissing 'New-PveTemplate' $attr = $script:Cmd.ImplementingType.GetCustomAttributes( [System.Management.Automation.CmdletAttribute], $false) | Select-Object -First 1 @@ -129,25 +48,8 @@ Describe 'New-PveTemplate' { } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'New-PveTemplate' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'VmId should be Mandatory' { - Skip-IfMissing 'New-PveTemplate' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active (without -WhatIf)' { - Skip-IfMissing 'New-PveTemplate' { New-PveTemplate -Node 'pve-node1' -VmId 9000 -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -158,102 +60,36 @@ Describe 'New-PveTemplate' { # Remove-PveTemplate # --------------------------------------------------------------------------- Describe 'Remove-PveTemplate' { - - BeforeAll { $script:Cmd = Get-Command 'Remove-PveTemplate' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Remove-PveTemplate' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Remove-PveTemplate' } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { - Skip-IfMissing 'Remove-PveTemplate' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High' { - Skip-IfMissing 'Remove-PveTemplate' $attr = $script:Cmd.ImplementingType.GetCustomAttributes( [System.Management.Automation.CmdletAttribute], $false) | Select-Object -First 1 $attr.ConfirmImpact | Should -Be ([System.Management.Automation.ConfirmImpact]::High) } } - - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Remove-PveTemplate' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'VmId should be Mandatory' { - Skip-IfMissing 'Remove-PveTemplate' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } } # --------------------------------------------------------------------------- # New-PveVmFromTemplate (deploy a new VM from a template) # --------------------------------------------------------------------------- Describe 'New-PveVmFromTemplate' { - - BeforeAll { $script:Cmd = Get-Command 'New-PveVmFromTemplate' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PveVmFromTemplate' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'New-PveVmFromTemplate' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'New-PveVmFromTemplate' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'TemplateNode should be Mandatory (node hosting the template)' { - Skip-IfMissing 'New-PveVmFromTemplate' - $hasTemplateNode = $script:Cmd.Parameters.ContainsKey('TemplateNode') -or - $script:Cmd.Parameters.ContainsKey('SourceNode') - $hasTemplateNode | Should -BeTrue - } - - It 'TemplateId (or VmId) should be Mandatory' { - Skip-IfMissing 'New-PveVmFromTemplate' - $hasId = $script:Cmd.Parameters.ContainsKey('TemplateId') -or - $script:Cmd.Parameters.ContainsKey('VmId') - $hasId | Should -BeTrue - } - } - - Context 'Optional parameters' { - It 'Should have NewName parameter (name for the deployed VM)' { - Skip-IfMissing 'New-PveVmFromTemplate' - $hasNewName = $script:Cmd.Parameters.ContainsKey('NewName') -or - $script:Cmd.Parameters.ContainsKey('Name') - $hasNewName | Should -BeTrue - } - - It 'Should have Wait switch parameter' { - Skip-IfMissing 'New-PveVmFromTemplate' - $script:Cmd.Parameters.ContainsKey('Wait') | Should -BeTrue - } - } - Context 'Without active session' { It 'Should throw when no session is active (without -WhatIf)' { - Skip-IfMissing 'New-PveVmFromTemplate' # Use whatever the first mandatory parameter is named; -ErrorAction Stop # will trigger the missing-mandatory-parameter error or the no-session error. { diff --git a/tests/PSProxmoxVE.Tests/Users/AccessManagementCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Users/AccessManagementCmdlets.Tests.ps1 index a2704c9..3f76ac3 100644 --- a/tests/PSProxmoxVE.Tests/Users/AccessManagementCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Users/AccessManagementCmdlets.Tests.ps1 @@ -6,55 +6,20 @@ Get-PveDomain, New-PveDomain, Set-PveDomain, Remove-PveDomain, Set-PvePassword. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:Availability = @{} - foreach ($name in @( - 'Get-PveGroup', 'New-PveGroup', 'Set-PveGroup', 'Remove-PveGroup', - 'Get-PveDomain', 'New-PveDomain', 'Set-PveDomain', 'Remove-PveDomain', 'Set-PvePassword' - )) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } } # --------------------------------------------------------------------------- # Get-PveGroup # --------------------------------------------------------------------------- Describe 'Get-PveGroup' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveGroup' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveGroup' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveGroup' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Parameter metadata' { - It 'Should have optional GroupId parameter' { - Skip-IfMissing 'Get-PveGroup' - $script:Cmd.Parameters.ContainsKey('GroupId') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveGroup' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveGroup' { Get-PveGroup -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -65,35 +30,16 @@ Describe 'Get-PveGroup' -Tag 'Unit' { # New-PveGroup # --------------------------------------------------------------------------- Describe 'New-PveGroup' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'New-PveGroup' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PveGroup' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'New-PveGroup' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'New-PveGroup' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'GroupId should be Mandatory' { - Skip-IfMissing 'New-PveGroup' - $isMandatory = $script:Cmd.Parameters['GroupId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'New-PveGroup' { New-PveGroup -GroupId 'testgroup' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -104,35 +50,16 @@ Describe 'New-PveGroup' -Tag 'Unit' { # Set-PveGroup # --------------------------------------------------------------------------- Describe 'Set-PveGroup' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Set-PveGroup' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Set-PveGroup' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Set-PveGroup' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Set-PveGroup' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'GroupId should be Mandatory' { - Skip-IfMissing 'Set-PveGroup' - $isMandatory = $script:Cmd.Parameters['GroupId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Set-PveGroup' { Set-PveGroup -GroupId 'testgroup' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -143,23 +70,13 @@ Describe 'Set-PveGroup' -Tag 'Unit' { # Remove-PveGroup # --------------------------------------------------------------------------- Describe 'Remove-PveGroup' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Remove-PveGroup' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Remove-PveGroup' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Remove-PveGroup' } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { - Skip-IfMissing 'Remove-PveGroup' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High' { - Skip-IfMissing 'Remove-PveGroup' $attr = $script:Cmd.ImplementingType.GetCustomAttributes( [System.Management.Automation.CmdletAttribute], $false) | Select-Object -First 1 @@ -167,18 +84,8 @@ Describe 'Remove-PveGroup' -Tag 'Unit' { } } - Context 'Required parameters' { - It 'GroupId should be Mandatory' { - Skip-IfMissing 'Remove-PveGroup' - $isMandatory = $script:Cmd.Parameters['GroupId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Remove-PveGroup' { Remove-PveGroup -GroupId 'testgroup' -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -189,30 +96,10 @@ Describe 'Remove-PveGroup' -Tag 'Unit' { # Get-PveDomain # --------------------------------------------------------------------------- Describe 'Get-PveDomain' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveDomain' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveDomain' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveDomain' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Parameter metadata' { - It 'Should have optional Realm parameter' { - Skip-IfMissing 'Get-PveDomain' - $script:Cmd.Parameters.ContainsKey('Realm') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveDomain' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveDomain' { Get-PveDomain -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -223,41 +110,16 @@ Describe 'Get-PveDomain' -Tag 'Unit' { # New-PveDomain # --------------------------------------------------------------------------- Describe 'New-PveDomain' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'New-PveDomain' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PveDomain' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'New-PveDomain' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'New-PveDomain' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Realm should be Mandatory' { - Skip-IfMissing 'New-PveDomain' - $isMandatory = $script:Cmd.Parameters['Realm'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Type should be Mandatory' { - Skip-IfMissing 'New-PveDomain' - $isMandatory = $script:Cmd.Parameters['Type'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'New-PveDomain' { New-PveDomain -Realm 'testrealm' -Type 'pve' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -268,35 +130,16 @@ Describe 'New-PveDomain' -Tag 'Unit' { # Set-PveDomain # --------------------------------------------------------------------------- Describe 'Set-PveDomain' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Set-PveDomain' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Set-PveDomain' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Set-PveDomain' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Set-PveDomain' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Realm should be Mandatory' { - Skip-IfMissing 'Set-PveDomain' - $isMandatory = $script:Cmd.Parameters['Realm'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Set-PveDomain' { Set-PveDomain -Realm 'testrealm' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -307,23 +150,13 @@ Describe 'Set-PveDomain' -Tag 'Unit' { # Remove-PveDomain # --------------------------------------------------------------------------- Describe 'Remove-PveDomain' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Remove-PveDomain' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Remove-PveDomain' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Remove-PveDomain' } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { - Skip-IfMissing 'Remove-PveDomain' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High' { - Skip-IfMissing 'Remove-PveDomain' $attr = $script:Cmd.ImplementingType.GetCustomAttributes( [System.Management.Automation.CmdletAttribute], $false) | Select-Object -First 1 @@ -331,18 +164,8 @@ Describe 'Remove-PveDomain' -Tag 'Unit' { } } - Context 'Required parameters' { - It 'Realm should be Mandatory' { - Skip-IfMissing 'Remove-PveDomain' - $isMandatory = $script:Cmd.Parameters['Realm'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Remove-PveDomain' { Remove-PveDomain -Realm 'testrealm' -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -353,45 +176,16 @@ Describe 'Remove-PveDomain' -Tag 'Unit' { # Set-PvePassword # --------------------------------------------------------------------------- Describe 'Set-PvePassword' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Set-PvePassword' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Set-PvePassword' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Set-PvePassword' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Set-PvePassword' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Set-PvePassword' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'UserId should be Mandatory' { - Skip-IfMissing 'Set-PvePassword' - $isMandatory = $script:Cmd.Parameters['UserId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Password should be Mandatory' { - Skip-IfMissing 'Set-PvePassword' - $isMandatory = $script:Cmd.Parameters['Password'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Set-PvePassword' $secPw = ConvertTo-SecureString 'dummypassword' -AsPlainText -Force { Set-PvePassword -UserId 'root@pam' -Password $secPw -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' diff --git a/tests/PSProxmoxVE.Tests/Users/ApiTokenCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Users/ApiTokenCmdlets.Tests.ps1 index 80f556c..ececda6 100644 --- a/tests/PSProxmoxVE.Tests/Users/ApiTokenCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Users/ApiTokenCmdlets.Tests.ps1 @@ -5,100 +5,30 @@ Get-PveApiToken, New-PveApiToken, Remove-PveApiToken. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 $allNames = @('Get-PveApiToken', 'New-PveApiToken', 'Remove-PveApiToken') - - $script:Availability = @{} - foreach ($name in $allNames) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } -} - -# --------------------------------------------------------------------------- -# Manifest contract -# --------------------------------------------------------------------------- -Describe 'API Token cmdlets — manifest declarations' { - BeforeAll { - $manifestPath = Join-Path (Get-Module PSProxmoxVE).ModuleBase 'PSProxmoxVE.psd1' - $script:Manifest = if (Test-Path $manifestPath) { Import-PowerShellDataFile $manifestPath } else { $null } - } - - It " should be declared in CmdletsToExport" -TestCases @( - @{ cmdName = 'Get-PveApiToken' } - @{ cmdName = 'New-PveApiToken' } - @{ cmdName = 'Remove-PveApiToken' } - ) { - if ($null -eq $script:Manifest) { Set-ItResult -Skipped -Because 'Manifest not found'; return } - $script:Manifest.CmdletsToExport | Should -Contain $cmdName - } } # --------------------------------------------------------------------------- # Get-PveApiToken # --------------------------------------------------------------------------- Describe 'Get-PveApiToken' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveApiToken' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveApiToken' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveApiToken' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveApiToken' } Context 'Parameter metadata' { - It 'Should have UserId as mandatory parameter' { - Skip-IfMissing 'Get-PveApiToken' - $isMandatory = $script:Cmd.Parameters['UserId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'UserId should accept pipeline input by property name' { - Skip-IfMissing 'Get-PveApiToken' $byPropName = $script:Cmd.Parameters['UserId'].ParameterSets.Values | Where-Object { $_.ValueFromPipelineByPropertyName } $byPropName | Should -Not -BeNullOrEmpty } - - It 'Should have TokenId as optional filter parameter' { - Skip-IfMissing 'Get-PveApiToken' - $script:Cmd.Parameters.ContainsKey('TokenId') | Should -BeTrue - } - - It 'TokenId should not be Mandatory' { - Skip-IfMissing 'Get-PveApiToken' - $isMandatory = $script:Cmd.Parameters['TokenId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } - - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveApiToken' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveApiToken' { Get-PveApiToken -UserId 'admin@pam' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } } @@ -108,76 +38,28 @@ Describe 'Get-PveApiToken' { # New-PveApiToken # --------------------------------------------------------------------------- Describe 'New-PveApiToken' { - - BeforeAll { $script:Cmd = Get-Command 'New-PveApiToken' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PveApiToken' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'New-PveApiToken' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'New-PveApiToken' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'New-PveApiToken' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'WhatIf should not throw even without a session' { - Skip-IfMissing 'New-PveApiToken' { New-PveApiToken -UserId 'admin@pam' -TokenId 'test' -WhatIf } | Should -Not -Throw } } Context 'Required parameters' { - It 'UserId should be Mandatory' { - Skip-IfMissing 'New-PveApiToken' - $isMandatory = $script:Cmd.Parameters['UserId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'UserId should accept pipeline input by property name' { - Skip-IfMissing 'New-PveApiToken' $byPropName = $script:Cmd.Parameters['UserId'].ParameterSets.Values | Where-Object { $_.ValueFromPipelineByPropertyName } $byPropName | Should -Not -BeNullOrEmpty } - - It 'TokenId should be Mandatory' { - Skip-IfMissing 'New-PveApiToken' - $isMandatory = $script:Cmd.Parameters['TokenId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - - Context 'Optional parameters' { - It 'Should have Comment parameter' { - Skip-IfMissing 'New-PveApiToken' - $script:Cmd.Parameters.ContainsKey('Comment') | Should -BeTrue - } - - It 'Should have Expire parameter' { - Skip-IfMissing 'New-PveApiToken' - $script:Cmd.Parameters.ContainsKey('Expire') | Should -BeTrue - } - - It 'Should have PrivilegeSeparation switch' { - Skip-IfMissing 'New-PveApiToken' - $script:Cmd.Parameters.ContainsKey('PrivilegeSeparation') | Should -BeTrue - } } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'New-PveApiToken' { New-PveApiToken -UserId 'admin@pam' -TokenId 'test' -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } } @@ -187,29 +69,14 @@ Describe 'New-PveApiToken' { # Remove-PveApiToken # --------------------------------------------------------------------------- Describe 'Remove-PveApiToken' { - - BeforeAll { $script:Cmd = Get-Command 'Remove-PveApiToken' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Remove-PveApiToken' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Remove-PveApiToken' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Remove-PveApiToken' } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { - Skip-IfMissing 'Remove-PveApiToken' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High' { - Skip-IfMissing 'Remove-PveApiToken' $attr = $script:Cmd.ImplementingType.GetCustomAttributes( [System.Management.Automation.CmdletAttribute], $false) | Select-Object -First 1 @@ -218,29 +85,13 @@ Describe 'Remove-PveApiToken' { } Context 'Required parameters' { - It 'UserId should be Mandatory' { - Skip-IfMissing 'Remove-PveApiToken' - $isMandatory = $script:Cmd.Parameters['UserId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'UserId should accept pipeline input by property name' { - Skip-IfMissing 'Remove-PveApiToken' $byPropName = $script:Cmd.Parameters['UserId'].ParameterSets.Values | Where-Object { $_.ValueFromPipelineByPropertyName } $byPropName | Should -Not -BeNullOrEmpty } - It 'TokenId should be Mandatory' { - Skip-IfMissing 'Remove-PveApiToken' - $isMandatory = $script:Cmd.Parameters['TokenId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'TokenId should accept pipeline input by property name' { - Skip-IfMissing 'Remove-PveApiToken' $byPropName = $script:Cmd.Parameters['TokenId'].ParameterSets.Values | Where-Object { $_.ValueFromPipelineByPropertyName } $byPropName | Should -Not -BeNullOrEmpty @@ -249,7 +100,6 @@ Describe 'Remove-PveApiToken' { Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Remove-PveApiToken' { Remove-PveApiToken -UserId 'admin@pam' -TokenId 'test' -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } } diff --git a/tests/PSProxmoxVE.Tests/Users/RoleCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Users/RoleCmdlets.Tests.ps1 index 2242a44..e40e96a 100644 --- a/tests/PSProxmoxVE.Tests/Users/RoleCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Users/RoleCmdlets.Tests.ps1 @@ -5,83 +5,30 @@ New-PveRole, Remove-PveRole. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:Availability = @{} - foreach ($name in @('New-PveRole', 'Remove-PveRole')) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } -} - -# --------------------------------------------------------------------------- -# Manifest contract -# --------------------------------------------------------------------------- -Describe 'Role cmdlets — manifest declarations' { - BeforeAll { - $manifestPath = Join-Path (Get-Module PSProxmoxVE).ModuleBase 'PSProxmoxVE.psd1' - $script:Manifest = if (Test-Path $manifestPath) { Import-PowerShellDataFile $manifestPath } else { $null } - } - - It " should be declared in CmdletsToExport" -TestCases @( - @{ cmdName = 'New-PveRole' } - @{ cmdName = 'Remove-PveRole' } - ) { - if ($null -eq $script:Manifest) { Set-ItResult -Skipped -Because 'Manifest not found'; return } - $script:Manifest.CmdletsToExport | Should -Contain $cmdName - } } # --------------------------------------------------------------------------- # New-PveRole # --------------------------------------------------------------------------- Describe 'New-PveRole' { - - BeforeAll { $script:Cmd = Get-Command 'New-PveRole' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PveRole' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'New-PveRole' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'New-PveRole' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'New-PveRole' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should support Confirm' { - Skip-IfMissing 'New-PveRole' $script:Cmd.Parameters.ContainsKey('Confirm') | Should -BeTrue } } Context 'Required parameters' { - It 'RoleId should be Mandatory' { - Skip-IfMissing 'New-PveRole' - $isMandatory = $script:Cmd.Parameters['RoleId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'RoleId should be at Position 0' { - Skip-IfMissing 'New-PveRole' $pos = $script:Cmd.Parameters['RoleId'].ParameterSets.Values | ForEach-Object { $_.Position } $pos | Should -Contain 0 @@ -89,36 +36,15 @@ Describe 'New-PveRole' { } Context 'Optional parameters' { - It 'Should have Privileges parameter' { - Skip-IfMissing 'New-PveRole' - $script:Cmd.Parameters.ContainsKey('Privileges') | Should -BeTrue - } - - It 'Privileges should not be Mandatory' { - Skip-IfMissing 'New-PveRole' - $isMandatory = $script:Cmd.Parameters['Privileges'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } - It 'Privileges should be at Position 1' { - Skip-IfMissing 'New-PveRole' $pos = $script:Cmd.Parameters['Privileges'].ParameterSets.Values | ForEach-Object { $_.Position } $pos | Should -Contain 1 } } - Context 'Session parameter' { - It 'Should have Session parameter (inherited from PveCmdletBase)' { - Skip-IfMissing 'New-PveRole' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'New-PveRole' { New-PveRole -RoleId 'TestRole' -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -129,43 +55,20 @@ Describe 'New-PveRole' { # Remove-PveRole # --------------------------------------------------------------------------- Describe 'Remove-PveRole' { - - BeforeAll { $script:Cmd = Get-Command 'Remove-PveRole' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Remove-PveRole' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Remove-PveRole' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Remove-PveRole' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Remove-PveRole' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should support Confirm' { - Skip-IfMissing 'Remove-PveRole' $script:Cmd.Parameters.ContainsKey('Confirm') | Should -BeTrue } } Context 'Required parameters' { - It 'RoleId should be Mandatory' { - Skip-IfMissing 'Remove-PveRole' - $isMandatory = $script:Cmd.Parameters['RoleId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'RoleId should be at Position 0' { - Skip-IfMissing 'Remove-PveRole' $pos = $script:Cmd.Parameters['RoleId'].ParameterSets.Values | ForEach-Object { $_.Position } $pos | Should -Contain 0 @@ -174,7 +77,6 @@ Describe 'Remove-PveRole' { Context 'Pipeline support' { It 'RoleId should accept pipeline input by property name' { - Skip-IfMissing 'Remove-PveRole' $roleId = $script:Cmd.Parameters['RoleId'] $acceptsByPropName = $roleId.ParameterSets.Values | Where-Object { $_.ValueFromPipelineByPropertyName } @@ -182,16 +84,8 @@ Describe 'Remove-PveRole' { } } - Context 'Session parameter' { - It 'Should have Session parameter (inherited from PveCmdletBase)' { - Skip-IfMissing 'Remove-PveRole' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Remove-PveRole' { Remove-PveRole -RoleId 'TestRole' -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } diff --git a/tests/PSProxmoxVE.Tests/Users/UserCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Users/UserCmdlets.Tests.ps1 index 20769b3..9e3b5cb 100644 --- a/tests/PSProxmoxVE.Tests/Users/UserCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Users/UserCmdlets.Tests.ps1 @@ -7,7 +7,6 @@ Get-PvePermission, Set-PvePermission. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. #> BeforeAll { @@ -18,93 +17,16 @@ BeforeAll { 'Get-PveRole', 'New-PveRole', 'Remove-PveRole', 'Get-PvePermission', 'Set-PvePermission' ) - - $script:Availability = @{} - foreach ($name in $allNames) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } -} - -# --------------------------------------------------------------------------- -# Manifest contract -# --------------------------------------------------------------------------- -Describe 'User / Role / Permission cmdlets — manifest declarations' { - BeforeAll { - $manifestPath = Join-Path (Get-Module PSProxmoxVE).ModuleBase 'PSProxmoxVE.psd1' - $script:Manifest = if (Test-Path $manifestPath) { Import-PowerShellDataFile $manifestPath } else { $null } - } - - It " should be declared in CmdletsToExport" -TestCases @( - @{ cmdName = 'Get-PveUser' } - @{ cmdName = 'New-PveUser' } - @{ cmdName = 'Remove-PveUser' } - @{ cmdName = 'Set-PveUser' } - @{ cmdName = 'Get-PveRole' } - @{ cmdName = 'New-PveRole' } - @{ cmdName = 'Remove-PveRole' } - @{ cmdName = 'Get-PvePermission' } - @{ cmdName = 'Set-PvePermission' } - ) { - if ($null -eq $script:Manifest) { Set-ItResult -Skipped -Because 'Manifest not found'; return } - $script:Manifest.CmdletsToExport | Should -Contain $cmdName - } } # --------------------------------------------------------------------------- # Get-PveUser # --------------------------------------------------------------------------- Describe 'Get-PveUser' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveUser' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveUser' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveUser' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Parameter metadata' { - It 'Should have UserId parameter (optional filter)' { - Skip-IfMissing 'Get-PveUser' - $script:Cmd.Parameters.ContainsKey('UserId') | Should -BeTrue - } - - It 'UserId should not be Mandatory' { - Skip-IfMissing 'Get-PveUser' - $isMandatory = $script:Cmd.Parameters['UserId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } - - It 'Should have Enabled switch or parameter to filter by enabled state' { - Skip-IfMissing 'Get-PveUser' - # Either an 'Enabled' switch or a filter parameter is expected. - $hasEnabled = $script:Cmd.Parameters.ContainsKey('Enabled') -or - $script:Cmd.Parameters.ContainsKey('EnabledOnly') - $hasEnabled | Should -BeTrue - } - - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveUser' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveUser' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveUser' { Get-PveUser -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -115,151 +37,56 @@ Describe 'Get-PveUser' { # New-PveUser # --------------------------------------------------------------------------- Describe 'New-PveUser' { - - BeforeAll { $script:Cmd = Get-Command 'New-PveUser' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'New-PveUser' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'New-PveUser' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'New-PveUser' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - - Context 'Required parameters' { - It 'UserId should be Mandatory (must include realm, e.g. user@pam)' { - Skip-IfMissing 'New-PveUser' - $isMandatory = $script:Cmd.Parameters['UserId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - - Context 'Optional parameters' { - It 'Should have Password parameter' { - Skip-IfMissing 'New-PveUser' - $hasPassword = $script:Cmd.Parameters.ContainsKey('Password') -or - $script:Cmd.Parameters.ContainsKey('Credential') - $hasPassword | Should -BeTrue - } - - It 'Should have Email parameter' { - Skip-IfMissing 'New-PveUser' - $script:Cmd.Parameters.ContainsKey('Email') | Should -BeTrue - } - - It 'Should have Groups parameter' { - Skip-IfMissing 'New-PveUser' - $script:Cmd.Parameters.ContainsKey('Groups') | Should -BeTrue - } - } } # --------------------------------------------------------------------------- # Remove-PveUser # --------------------------------------------------------------------------- Describe 'Remove-PveUser' { - - BeforeAll { $script:Cmd = Get-Command 'Remove-PveUser' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Remove-PveUser' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Remove-PveUser' } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { - Skip-IfMissing 'Remove-PveUser' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High' { - Skip-IfMissing 'Remove-PveUser' $attr = $script:Cmd.ImplementingType.GetCustomAttributes( [System.Management.Automation.CmdletAttribute], $false) | Select-Object -First 1 $attr.ConfirmImpact | Should -Be ([System.Management.Automation.ConfirmImpact]::High) } } - - Context 'Required parameters' { - It 'UserId should be Mandatory' { - Skip-IfMissing 'Remove-PveUser' - $isMandatory = $script:Cmd.Parameters['UserId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } } # --------------------------------------------------------------------------- # Set-PveUser # --------------------------------------------------------------------------- Describe 'Set-PveUser' { - - BeforeAll { $script:Cmd = Get-Command 'Set-PveUser' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Set-PveUser' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Set-PveUser' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Set-PveUser' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - - Context 'Required parameters' { - It 'UserId should be Mandatory' { - Skip-IfMissing 'Set-PveUser' - $isMandatory = $script:Cmd.Parameters['UserId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } } # --------------------------------------------------------------------------- # Get-PveRole # --------------------------------------------------------------------------- Describe 'Get-PveRole' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveRole' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveRole' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } - - Context 'Parameter metadata' { - It 'Should have RoleId parameter (optional filter)' { - Skip-IfMissing 'Get-PveRole' - $script:Cmd.Parameters.ContainsKey('RoleId') | Should -BeTrue - } - - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveRole' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveRole' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveRole' { Get-PveRole -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -270,36 +97,10 @@ Describe 'Get-PveRole' { # Get-PvePermission # --------------------------------------------------------------------------- Describe 'Get-PvePermission' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PvePermission' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PvePermission' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } - - Context 'Parameter metadata' { - It 'Should have UserId parameter' { - Skip-IfMissing 'Get-PvePermission' - $script:Cmd.Parameters.ContainsKey('UserId') | Should -BeTrue - } - - It 'Should have Path parameter (ACL path, optional)' { - Skip-IfMissing 'Get-PvePermission' - $script:Cmd.Parameters.ContainsKey('Path') | Should -BeTrue - } - - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PvePermission' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PvePermission' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PvePermission' { Get-PvePermission -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -310,36 +111,11 @@ Describe 'Get-PvePermission' { # Set-PvePermission # --------------------------------------------------------------------------- Describe 'Set-PvePermission' { - - BeforeAll { $script:Cmd = Get-Command 'Set-PvePermission' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Set-PvePermission' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Set-PvePermission' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Set-PvePermission' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - - Context 'Required parameters' { - It 'Path should be Mandatory (the ACL path, e.g. / or /vms/100)' { - Skip-IfMissing 'Set-PvePermission' - $isMandatory = $script:Cmd.Parameters['Path'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Role should be Mandatory' { - Skip-IfMissing 'Set-PvePermission' - $isMandatory = $script:Cmd.Parameters['Role'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } } diff --git a/tests/PSProxmoxVE.Tests/Vms/Get-PveVm.Tests.ps1 b/tests/PSProxmoxVE.Tests/Vms/Get-PveVm.Tests.ps1 index 2df2220..3ac3709 100644 --- a/tests/PSProxmoxVE.Tests/Vms/Get-PveVm.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Vms/Get-PveVm.Tests.ps1 @@ -10,33 +10,11 @@ BeforeAll { } Describe 'Get-PveVm' { - - Context 'Command existence' { - It 'Should be available after module import' { - Get-Command 'Get-PveVm' -ErrorAction SilentlyContinue | - Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - (Get-Command 'Get-PveVm').CommandType | Should -Be 'Cmdlet' - } - } - Context 'Parameter validation' { BeforeAll { $script:Cmd = Get-Command 'Get-PveVm' } - It 'Should have Node parameter' { - $script:Cmd.Parameters.ContainsKey('Node') | Should -BeTrue - } - - It 'Node should not be Mandatory (all-nodes query when omitted)' { - $node = $script:Cmd.Parameters['Node'] - $isMandatory = $node.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } - It 'Node should accept pipeline input by property name' { $node = $script:Cmd.Parameters['Node'] $acceptsByPropName = $node.ParameterSets.Values | @@ -44,32 +22,12 @@ Describe 'Get-PveVm' { $acceptsByPropName | Should -Not -BeNullOrEmpty } - It 'Should have VmId parameter' { - $script:Cmd.Parameters.ContainsKey('VmId') | Should -BeTrue - } - - It 'Should have Name parameter' { - $script:Cmd.Parameters.ContainsKey('Name') | Should -BeTrue - } - - It 'Should have Status parameter' { - $script:Cmd.Parameters.ContainsKey('Status') | Should -BeTrue - } - - It 'Should have Tag parameter' { - $script:Cmd.Parameters.ContainsKey('Tag') | Should -BeTrue - } - It 'Should have TemplatesOnly switch parameter' { $script:Cmd.Parameters.ContainsKey('TemplatesOnly') | Should -BeTrue $script:Cmd.Parameters['TemplatesOnly'].ParameterType | Should -Be ([System.Management.Automation.SwitchParameter]) } - It 'Should have Session parameter (inherited from PveCmdletBase)' { - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - It 'None of the filter parameters should be Mandatory' { foreach ($paramName in @('Node', 'VmId', 'Name', 'Status', 'Tag', 'TemplatesOnly', 'Session')) { $p = $script:Cmd.Parameters[$paramName] diff --git a/tests/PSProxmoxVE.Tests/Vms/GuestAgentCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Vms/GuestAgentCmdlets.Tests.ps1 index bfe6943..d55b824 100644 --- a/tests/PSProxmoxVE.Tests/Vms/GuestAgentCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Vms/GuestAgentCmdlets.Tests.ps1 @@ -5,86 +5,26 @@ Test-PveVmGuestAgent, Get-PveVmGuestNetwork, Invoke-PveVmGuestExec. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:Availability = @{} - foreach ($name in @('Test-PveVmGuestAgent', 'Get-PveVmGuestNetwork', 'Invoke-PveVmGuestExec')) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } -} - -# --------------------------------------------------------------------------- -# Manifest contract -# --------------------------------------------------------------------------- -Describe 'Guest agent cmdlets — manifest declarations' { - BeforeAll { - $manifestPath = Join-Path (Get-Module PSProxmoxVE).ModuleBase 'PSProxmoxVE.psd1' - $script:Manifest = if (Test-Path $manifestPath) { Import-PowerShellDataFile $manifestPath } else { $null } - } - - It " should be declared in CmdletsToExport" -TestCases @( - @{ cmdName = 'Test-PveVmGuestAgent' } - @{ cmdName = 'Get-PveVmGuestNetwork' } - @{ cmdName = 'Invoke-PveVmGuestExec' } - ) { - if ($null -eq $script:Manifest) { Set-ItResult -Skipped -Because 'Manifest not found'; return } - $script:Manifest.CmdletsToExport | Should -Contain $cmdName - } } # --------------------------------------------------------------------------- # Test-PveVmGuestAgent # --------------------------------------------------------------------------- Describe 'Test-PveVmGuestAgent' { - - BeforeAll { $script:Cmd = Get-Command 'Test-PveVmGuestAgent' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Test-PveVmGuestAgent' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Test-PveVmGuestAgent' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Test-PveVmGuestAgent' } Context 'Parameter metadata' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Test-PveVmGuestAgent' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'VmId should be Mandatory' { - Skip-IfMissing 'Test-PveVmGuestAgent' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'VmId should accept pipeline input by property name' { - Skip-IfMissing 'Test-PveVmGuestAgent' $attr = $script:Cmd.Parameters['VmId'].ParameterSets.Values | Where-Object { $_.ValueFromPipelineByPropertyName } $attr | Should -Not -BeNullOrEmpty } It 'Should output bool' { - Skip-IfMissing 'Test-PveVmGuestAgent' $outputType = $script:Cmd.OutputType | Select-Object -First 1 $outputType.Type | Should -Be ([bool]) } @@ -92,7 +32,6 @@ Describe 'Test-PveVmGuestAgent' { Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Test-PveVmGuestAgent' { Test-PveVmGuestAgent -Node 'pve1' -VmId 100 -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -103,52 +42,18 @@ Describe 'Test-PveVmGuestAgent' { # Get-PveVmGuestNetwork # --------------------------------------------------------------------------- Describe 'Get-PveVmGuestNetwork' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveVmGuestNetwork' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveVmGuestNetwork' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveVmGuestNetwork' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveVmGuestNetwork' } Context 'Parameter metadata' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Get-PveVmGuestNetwork' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'VmId should be Mandatory' { - Skip-IfMissing 'Get-PveVmGuestNetwork' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'VmId should accept pipeline input by property name' { - Skip-IfMissing 'Get-PveVmGuestNetwork' $attr = $script:Cmd.Parameters['VmId'].ParameterSets.Values | Where-Object { $_.ValueFromPipelineByPropertyName } $attr | Should -Not -BeNullOrEmpty } - - It 'Should have Session parameter' { - Skip-IfMissing 'Get-PveVmGuestNetwork' - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveVmGuestNetwork' { Get-PveVmGuestNetwork -Node 'pve1' -VmId 100 -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -159,58 +64,21 @@ Describe 'Get-PveVmGuestNetwork' { # Invoke-PveVmGuestExec # --------------------------------------------------------------------------- Describe 'Invoke-PveVmGuestExec' { - - BeforeAll { $script:Cmd = Get-Command 'Invoke-PveVmGuestExec' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Invoke-PveVmGuestExec' - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Invoke-PveVmGuestExec' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Invoke-PveVmGuestExec' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Invoke-PveVmGuestExec' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Invoke-PveVmGuestExec' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'VmId should be Mandatory' { - Skip-IfMissing 'Invoke-PveVmGuestExec' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Command should be Mandatory' { - Skip-IfMissing 'Invoke-PveVmGuestExec' - $isMandatory = $script:Cmd.Parameters['Command'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Should have Timeout parameter of type int' { - Skip-IfMissing 'Invoke-PveVmGuestExec' $script:Cmd.Parameters.ContainsKey('Timeout') | Should -BeTrue $script:Cmd.Parameters['Timeout'].ParameterType | Should -Be ([int]) } It 'Timeout should have ValidateRange(1,3600)' { - Skip-IfMissing 'Invoke-PveVmGuestExec' $rangeAttr = $script:Cmd.Parameters['Timeout'].Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateRangeAttribute] } $rangeAttr | Should -Not -BeNullOrEmpty @@ -221,7 +89,6 @@ Describe 'Invoke-PveVmGuestExec' { Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Invoke-PveVmGuestExec' { Invoke-PveVmGuestExec -Node 'pve1' -VmId 100 -Command 'hostname' -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } diff --git a/tests/PSProxmoxVE.Tests/Vms/GuestAgentExtCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Vms/GuestAgentExtCmdlets.Tests.ps1 index 3ad76e4..f0c1cdb 100644 --- a/tests/PSProxmoxVE.Tests/Vms/GuestAgentExtCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Vms/GuestAgentExtCmdlets.Tests.ps1 @@ -6,63 +6,20 @@ Write-PveVmGuestFile, Set-PveVmGuestPassword, Invoke-PveVmGuestFsTrim. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:Availability = @{} - foreach ($name in @( - 'Get-PveVmGuestOsInfo', 'Get-PveVmGuestFsInfo', 'Read-PveVmGuestFile', - 'Write-PveVmGuestFile', 'Set-PveVmGuestPassword', 'Invoke-PveVmGuestFsTrim' - )) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } } # --------------------------------------------------------------------------- # Get-PveVmGuestOsInfo # --------------------------------------------------------------------------- Describe 'Get-PveVmGuestOsInfo' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveVmGuestOsInfo' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveVmGuestOsInfo' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveVmGuestOsInfo' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Get-PveVmGuestOsInfo' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'VmId should be Mandatory' { - Skip-IfMissing 'Get-PveVmGuestOsInfo' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveVmGuestOsInfo' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveVmGuestOsInfo' { Get-PveVmGuestOsInfo -Node 'pve' -VmId 100 -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -73,38 +30,10 @@ Describe 'Get-PveVmGuestOsInfo' -Tag 'Unit' { # Get-PveVmGuestFsInfo # --------------------------------------------------------------------------- Describe 'Get-PveVmGuestFsInfo' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Get-PveVmGuestFsInfo' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Get-PveVmGuestFsInfo' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Get-PveVmGuestFsInfo' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Get-PveVmGuestFsInfo' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'VmId should be Mandatory' { - Skip-IfMissing 'Get-PveVmGuestFsInfo' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Get-PveVmGuestFsInfo' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Get-PveVmGuestFsInfo' { Get-PveVmGuestFsInfo -Node 'pve' -VmId 100 -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -115,44 +44,10 @@ Describe 'Get-PveVmGuestFsInfo' -Tag 'Unit' { # Read-PveVmGuestFile # --------------------------------------------------------------------------- Describe 'Read-PveVmGuestFile' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Read-PveVmGuestFile' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Read-PveVmGuestFile' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Read-PveVmGuestFile' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Read-PveVmGuestFile' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'VmId should be Mandatory' { - Skip-IfMissing 'Read-PveVmGuestFile' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'File should be Mandatory' { - Skip-IfMissing 'Read-PveVmGuestFile' - $isMandatory = $script:Cmd.Parameters['File'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Read-PveVmGuestFile' } Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Read-PveVmGuestFile' { Read-PveVmGuestFile -Node 'pve' -VmId 100 -File '/etc/hostname' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -163,57 +58,16 @@ Describe 'Read-PveVmGuestFile' -Tag 'Unit' { # Write-PveVmGuestFile # --------------------------------------------------------------------------- Describe 'Write-PveVmGuestFile' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Write-PveVmGuestFile' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Write-PveVmGuestFile' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Write-PveVmGuestFile' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Write-PveVmGuestFile' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Write-PveVmGuestFile' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Write-PveVmGuestFile' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'VmId should be Mandatory' { - Skip-IfMissing 'Write-PveVmGuestFile' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'File should be Mandatory' { - Skip-IfMissing 'Write-PveVmGuestFile' - $isMandatory = $script:Cmd.Parameters['File'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Content should be Mandatory' { - Skip-IfMissing 'Write-PveVmGuestFile' - $isMandatory = $script:Cmd.Parameters['Content'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Write-PveVmGuestFile' { Write-PveVmGuestFile -Node 'pve' -VmId 100 -File '/tmp/test.txt' -Content 'hello' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -224,57 +78,16 @@ Describe 'Write-PveVmGuestFile' -Tag 'Unit' { # Set-PveVmGuestPassword # --------------------------------------------------------------------------- Describe 'Set-PveVmGuestPassword' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Set-PveVmGuestPassword' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Set-PveVmGuestPassword' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Set-PveVmGuestPassword' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Set-PveVmGuestPassword' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Set-PveVmGuestPassword' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Set-PveVmGuestPassword' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'VmId should be Mandatory' { - Skip-IfMissing 'Set-PveVmGuestPassword' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Username should be Mandatory' { - Skip-IfMissing 'Set-PveVmGuestPassword' - $isMandatory = $script:Cmd.Parameters['Username'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Password should be Mandatory' { - Skip-IfMissing 'Set-PveVmGuestPassword' - $isMandatory = $script:Cmd.Parameters['Password'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Parameter types' { It 'Password should be SecureString' { - Skip-IfMissing 'Set-PveVmGuestPassword' $script:Cmd.Parameters['Password'].ParameterType | Should -Be ([System.Security.SecureString]) } @@ -282,7 +95,6 @@ Describe 'Set-PveVmGuestPassword' -Tag 'Unit' { Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Set-PveVmGuestPassword' $secPwd = ConvertTo-SecureString 'dummy' -AsPlainText -Force { Set-PveVmGuestPassword -Node 'pve' -VmId 100 -Username 'root' -Password $secPwd -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' @@ -294,45 +106,16 @@ Describe 'Set-PveVmGuestPassword' -Tag 'Unit' { # Invoke-PveVmGuestFsTrim # --------------------------------------------------------------------------- Describe 'Invoke-PveVmGuestFsTrim' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Invoke-PveVmGuestFsTrim' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Invoke-PveVmGuestFsTrim' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Invoke-PveVmGuestFsTrim' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Invoke-PveVmGuestFsTrim' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Invoke-PveVmGuestFsTrim' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Invoke-PveVmGuestFsTrim' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'VmId should be Mandatory' { - Skip-IfMissing 'Invoke-PveVmGuestFsTrim' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Invoke-PveVmGuestFsTrim' { Invoke-PveVmGuestFsTrim -Node 'pve' -VmId 100 -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } diff --git a/tests/PSProxmoxVE.Tests/Vms/ImportPveOva.Tests.ps1 b/tests/PSProxmoxVE.Tests/Vms/ImportPveOva.Tests.ps1 index e7ceb49..ef74931 100644 --- a/tests/PSProxmoxVE.Tests/Vms/ImportPveOva.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Vms/ImportPveOva.Tests.ps1 @@ -9,126 +9,30 @@ BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - $script:Cmd = Get-Command 'Import-PveOva' -ErrorAction SilentlyContinue - $script:Available = $null -ne $script:Cmd - - function Skip-IfMissing { - if (-not $script:Available) { - Set-ItResult -Skipped -Because "Import-PveOva is not yet implemented in this build" - } - } -} - -Describe 'Import-PveOva — manifest' { - BeforeAll { - $manifestPath = Join-Path (Get-Module PSProxmoxVE).ModuleBase 'PSProxmoxVE.psd1' - $script:Manifest = if (Test-Path $manifestPath) { Import-PowerShellDataFile $manifestPath } else { $null } - } - - It 'Should be declared in CmdletsToExport' { - if ($null -eq $script:Manifest) { Set-ItResult -Skipped -Because 'Manifest not found'; return } - $script:Manifest.CmdletsToExport | Should -Contain 'Import-PveOva' - } + $script:Cmd = Get-Command 'Import-PveOva' } Describe 'Import-PveOva' { - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should support Confirm' { - Skip-IfMissing $script:Cmd.Parameters.ContainsKey('Confirm') | Should -BeTrue } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Storage should be Mandatory' { - Skip-IfMissing - $isMandatory = $script:Cmd.Parameters['Storage'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Path should be Mandatory' { - Skip-IfMissing - $isMandatory = $script:Cmd.Parameters['Path'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'TargetStorage should be Mandatory' { - Skip-IfMissing - $isMandatory = $script:Cmd.Parameters['TargetStorage'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Optional parameters' { - It 'Should have VmId parameter' { - Skip-IfMissing - $script:Cmd.Parameters.ContainsKey('VmId') | Should -BeTrue - } - It 'VmId should not be Mandatory' { - Skip-IfMissing $allMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | Where-Object { $_.IsMandatory } $allMandatory | Should -BeNullOrEmpty } - - It 'Should have Name parameter' { - Skip-IfMissing - $script:Cmd.Parameters.ContainsKey('Name') | Should -BeTrue - } - - It 'Should have Memory parameter' { - Skip-IfMissing - $script:Cmd.Parameters.ContainsKey('Memory') | Should -BeTrue - } - - It 'Should have Cores parameter' { - Skip-IfMissing - $script:Cmd.Parameters.ContainsKey('Cores') | Should -BeTrue - } - - It 'Should have Wait switch parameter' { - Skip-IfMissing - $script:Cmd.Parameters.ContainsKey('Wait') | Should -BeTrue - } - - It 'Should have Session parameter' { - Skip-IfMissing - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } } Context 'Output type' { It 'Should declare PveVm as output type' { - Skip-IfMissing $outputTypes = $script:Cmd.OutputType | ForEach-Object { $_.Type.Name } $outputTypes | Should -Contain 'PveVm' } @@ -136,7 +40,6 @@ Describe 'Import-PveOva' { Context 'Without active session' { It 'Should throw when no session is active and file does not exist' { - Skip-IfMissing { Import-PveOva -Node 'pve1' -Storage 'local' -Path '/nonexistent/file.ova' ` -TargetStorage 'local-lvm' -Confirm:$false -ErrorAction Stop } | Should -Throw diff --git a/tests/PSProxmoxVE.Tests/Vms/ImportPveVmDisk.Tests.ps1 b/tests/PSProxmoxVE.Tests/Vms/ImportPveVmDisk.Tests.ps1 index d088c9a..908be29 100644 --- a/tests/PSProxmoxVE.Tests/Vms/ImportPveVmDisk.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Vms/ImportPveVmDisk.Tests.ps1 @@ -9,106 +9,18 @@ BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - $script:Cmd = Get-Command 'Import-PveVmDisk' -ErrorAction SilentlyContinue - $script:Available = $null -ne $script:Cmd - - function Skip-IfMissing { - if (-not $script:Available) { - Set-ItResult -Skipped -Because "Import-PveVmDisk is not yet implemented in this build" - } - } -} - -Describe 'Import-PveVmDisk — manifest' { - BeforeAll { - $manifestPath = Join-Path (Get-Module PSProxmoxVE).ModuleBase 'PSProxmoxVE.psd1' - $script:Manifest = if (Test-Path $manifestPath) { Import-PowerShellDataFile $manifestPath } else { $null } - } - - It 'Should be declared in CmdletsToExport' { - if ($null -eq $script:Manifest) { Set-ItResult -Skipped -Because 'Manifest not found'; return } - $script:Manifest.CmdletsToExport | Should -Contain 'Import-PveVmDisk' - } + $script:Cmd = Get-Command 'Import-PveVmDisk' } Describe 'Import-PveVmDisk' { - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing - $script:Cmd | Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } - Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'VmId should be Mandatory' { - Skip-IfMissing - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Disk should be Mandatory' { - Skip-IfMissing - $isMandatory = $script:Cmd.Parameters['Disk'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'TargetStorage should be Mandatory' { - Skip-IfMissing - $isMandatory = $script:Cmd.Parameters['TargetStorage'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Source should be Mandatory' { - Skip-IfMissing - $isMandatory = $script:Cmd.Parameters['Source'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - - Context 'Optional parameters' { - It 'Should have Format parameter' { - Skip-IfMissing - $script:Cmd.Parameters.ContainsKey('Format') | Should -BeTrue - } - - It 'Should have Wait switch parameter' { - Skip-IfMissing - $script:Cmd.Parameters.ContainsKey('Wait') | Should -BeTrue - } - - It 'Should have Session parameter' { - Skip-IfMissing - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - } - Context 'Disk parameter validation' { It 'Should accept valid disk names' { - Skip-IfMissing # ValidatePattern should accept these — test by checking the attribute exists $attrs = $script:Cmd.Parameters['Disk'].Attributes | Where-Object { $_ -is [System.Management.Automation.ValidatePatternAttribute] } @@ -118,14 +30,12 @@ Describe 'Import-PveVmDisk' { Context 'Pipeline support' { It 'VmId should accept pipeline input by property name' { - Skip-IfMissing $attr = $script:Cmd.Parameters['VmId'].ParameterSets.Values | Where-Object { $_.ValueFromPipelineByPropertyName } $attr | Should -Not -BeNullOrEmpty } It 'Node should accept pipeline input by property name' { - Skip-IfMissing $attr = $script:Cmd.Parameters['Node'].ParameterSets.Values | Where-Object { $_.ValueFromPipelineByPropertyName } $attr | Should -Not -BeNullOrEmpty @@ -134,7 +44,6 @@ Describe 'Import-PveVmDisk' { Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing { Import-PveVmDisk -Node 'pve1' -VmId 100 -Disk 'scsi0' ` -TargetStorage 'local-lvm' -Source 'local:iso/test.img' ` -Confirm:$false -ErrorAction Stop } | diff --git a/tests/PSProxmoxVE.Tests/Vms/New-PveVm.Tests.ps1 b/tests/PSProxmoxVE.Tests/Vms/New-PveVm.Tests.ps1 index af429ae..49cf215 100644 --- a/tests/PSProxmoxVE.Tests/Vms/New-PveVm.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Vms/New-PveVm.Tests.ps1 @@ -10,18 +10,6 @@ BeforeAll { } Describe 'New-PveVm' { - - Context 'Command existence' { - It 'Should be available after module import' { - Get-Command 'New-PveVm' -ErrorAction SilentlyContinue | - Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - (Get-Command 'New-PveVm').CommandType | Should -Be 'Cmdlet' - } - } - Context 'ShouldProcess support' { BeforeAll { $script:Cmd = Get-Command 'New-PveVm' @@ -41,75 +29,11 @@ Describe 'New-PveVm' { } } - Context 'Required parameter — Node' { - It 'Node should be Mandatory' { - $nodeParam = (Get-Command 'New-PveVm').Parameters['Node'] - $isMandatory = $nodeParam.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Optional parameter metadata' { BeforeAll { $script:Cmd = Get-Command 'New-PveVm' } - It 'Should have VmId parameter' { - $script:Cmd.Parameters.ContainsKey('VmId') | Should -BeTrue - } - - It 'Should have Name parameter' { - $script:Cmd.Parameters.ContainsKey('Name') | Should -BeTrue - } - - It 'Should have Memory parameter' { - $script:Cmd.Parameters.ContainsKey('Memory') | Should -BeTrue - } - - It 'Should have Cores parameter' { - $script:Cmd.Parameters.ContainsKey('Cores') | Should -BeTrue - } - - It 'Should have Sockets parameter' { - $script:Cmd.Parameters.ContainsKey('Sockets') | Should -BeTrue - } - - It 'Should have CpuType parameter' { - $script:Cmd.Parameters.ContainsKey('CpuType') | Should -BeTrue - } - - It 'Should have Bios parameter' { - $script:Cmd.Parameters.ContainsKey('Bios') | Should -BeTrue - } - - It 'Should have Machine parameter' { - $script:Cmd.Parameters.ContainsKey('Machine') | Should -BeTrue - } - - It 'Should have DiskSize parameter' { - $script:Cmd.Parameters.ContainsKey('DiskSize') | Should -BeTrue - } - - It 'Should have DiskStorage parameter' { - $script:Cmd.Parameters.ContainsKey('DiskStorage') | Should -BeTrue - } - - It 'Should have DiskFormat parameter' { - $script:Cmd.Parameters.ContainsKey('DiskFormat') | Should -BeTrue - } - - It 'Should have Network parameter' { - $script:Cmd.Parameters.ContainsKey('Network') | Should -BeTrue - } - - It 'Should have Bridge parameter' { - $script:Cmd.Parameters.ContainsKey('Bridge') | Should -BeTrue - } - - It 'Should have OsType parameter' { - $script:Cmd.Parameters.ContainsKey('OsType') | Should -BeTrue - } - It 'Should have Start switch parameter' { $script:Cmd.Parameters.ContainsKey('Start') | Should -BeTrue $script:Cmd.Parameters['Start'].ParameterType | @@ -121,10 +45,6 @@ Describe 'New-PveVm' { $script:Cmd.Parameters['Wait'].ParameterType | Should -Be ([System.Management.Automation.SwitchParameter]) } - - It 'Should have Session parameter (inherited from PveCmdletBase)' { - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } } Context 'Without active session' { diff --git a/tests/PSProxmoxVE.Tests/Vms/Remove-PveVm.Tests.ps1 b/tests/PSProxmoxVE.Tests/Vms/Remove-PveVm.Tests.ps1 index 641e30f..07e297c 100644 --- a/tests/PSProxmoxVE.Tests/Vms/Remove-PveVm.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Vms/Remove-PveVm.Tests.ps1 @@ -10,18 +10,6 @@ BeforeAll { } Describe 'Remove-PveVm' { - - Context 'Command existence' { - It 'Should be available after module import' { - Get-Command 'Remove-PveVm' -ErrorAction SilentlyContinue | - Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - (Get-Command 'Remove-PveVm').CommandType | Should -Be 'Cmdlet' - } - } - Context 'ShouldProcess / ConfirmImpact' { BeforeAll { $script:Cmd = Get-Command 'Remove-PveVm' @@ -51,12 +39,6 @@ Describe 'Remove-PveVm' { } Context 'Required parameters' { - It 'Node should be Mandatory' { - $nodeParam = (Get-Command 'Remove-PveVm').Parameters['Node'] - $isMandatory = $nodeParam.ParameterSets.Values | Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'VmId should be Mandatory' { $vmidParam = (Get-Command 'Remove-PveVm').Parameters['VmId'] $isMandatory = $vmidParam.ParameterSets.Values | Where-Object { $_.IsMandatory } diff --git a/tests/PSProxmoxVE.Tests/Vms/VmAdvancedOps.Tests.ps1 b/tests/PSProxmoxVE.Tests/Vms/VmAdvancedOps.Tests.ps1 index 8ae83c0..ca793002 100644 --- a/tests/PSProxmoxVE.Tests/Vms/VmAdvancedOps.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Vms/VmAdvancedOps.Tests.ps1 @@ -15,48 +15,18 @@ BeforeAll { # Copy-PveVm # --------------------------------------------------------------------------- Describe 'Copy-PveVm' { - - Context 'Command existence' { - It 'Should be available after module import' { - Get-Command 'Copy-PveVm' -ErrorAction SilentlyContinue | - Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - (Get-Command 'Copy-PveVm').CommandType | Should -Be 'Cmdlet' - } - } - Context 'Parameter metadata' { BeforeAll { $script:Cmd = Get-Command 'Copy-PveVm' } # --- SourceNode --- - It 'Should have SourceNode parameter' { - $script:Cmd.Parameters.ContainsKey('SourceNode') | Should -BeTrue - } - - It 'SourceNode should be Mandatory' { - $isMandatory = $script:Cmd.Parameters['SourceNode'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } It 'SourceNode should be of type String' { $script:Cmd.Parameters['SourceNode'].ParameterType | Should -Be ([string]) } # --- VmId --- - It 'Should have VmId parameter' { - $script:Cmd.Parameters.ContainsKey('VmId') | Should -BeTrue - } - - It 'VmId should be Mandatory' { - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } It 'VmId should be of type Int32' { $script:Cmd.Parameters['VmId'].ParameterType | Should -Be ([int]) @@ -69,15 +39,6 @@ Describe 'Copy-PveVm' { } # --- NewVmId (optional) --- - It 'Should have NewVmId parameter' { - $script:Cmd.Parameters.ContainsKey('NewVmId') | Should -BeTrue - } - - It 'NewVmId should not be Mandatory' { - $isMandatory = $script:Cmd.Parameters['NewVmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } It 'NewVmId should be of nullable Int32 type' { $script:Cmd.Parameters['NewVmId'].ParameterType | @@ -85,30 +46,12 @@ Describe 'Copy-PveVm' { } # --- NewName (optional) --- - It 'Should have NewName parameter' { - $script:Cmd.Parameters.ContainsKey('NewName') | Should -BeTrue - } - - It 'NewName should not be Mandatory' { - $isMandatory = $script:Cmd.Parameters['NewName'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } It 'NewName should be of type String' { $script:Cmd.Parameters['NewName'].ParameterType | Should -Be ([string]) } # --- TargetNode (optional) --- - It 'Should have TargetNode parameter' { - $script:Cmd.Parameters.ContainsKey('TargetNode') | Should -BeTrue - } - - It 'TargetNode should not be Mandatory' { - $isMandatory = $script:Cmd.Parameters['TargetNode'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } It 'TargetNode should be of type String' { $script:Cmd.Parameters['TargetNode'].ParameterType | Should -Be ([string]) @@ -121,22 +64,7 @@ Describe 'Copy-PveVm' { Should -Be ([System.Management.Automation.SwitchParameter]) } - It 'Full should not be Mandatory' { - $isMandatory = $script:Cmd.Parameters['Full'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } - # --- Storage (optional) --- - It 'Should have Storage parameter' { - $script:Cmd.Parameters.ContainsKey('Storage') | Should -BeTrue - } - - It 'Storage should not be Mandatory' { - $isMandatory = $script:Cmd.Parameters['Storage'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } It 'Storage should be of type String' { $script:Cmd.Parameters['Storage'].ParameterType | Should -Be ([string]) @@ -149,16 +77,7 @@ Describe 'Copy-PveVm' { Should -Be ([System.Management.Automation.SwitchParameter]) } - It 'Wait should not be Mandatory' { - $isMandatory = $script:Cmd.Parameters['Wait'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } - # --- Session (inherited) --- - It 'Should have Session parameter (inherited from PveCmdletBase)' { - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } } Context 'ShouldProcess support' { @@ -204,33 +123,12 @@ Describe 'Copy-PveVm' { # Move-PveVm # --------------------------------------------------------------------------- Describe 'Move-PveVm' { - - Context 'Command existence' { - It 'Should be available after module import' { - Get-Command 'Move-PveVm' -ErrorAction SilentlyContinue | - Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - (Get-Command 'Move-PveVm').CommandType | Should -Be 'Cmdlet' - } - } - Context 'Parameter metadata' { BeforeAll { $script:Cmd = Get-Command 'Move-PveVm' } # --- Node --- - It 'Should have Node parameter' { - $script:Cmd.Parameters.ContainsKey('Node') | Should -BeTrue - } - - It 'Node should be Mandatory' { - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } It 'Node should be of type String' { $script:Cmd.Parameters['Node'].ParameterType | Should -Be ([string]) @@ -243,15 +141,6 @@ Describe 'Move-PveVm' { } # --- VmId --- - It 'Should have VmId parameter' { - $script:Cmd.Parameters.ContainsKey('VmId') | Should -BeTrue - } - - It 'VmId should be Mandatory' { - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } It 'VmId should be of type Int32' { $script:Cmd.Parameters['VmId'].ParameterType | Should -Be ([int]) @@ -264,15 +153,6 @@ Describe 'Move-PveVm' { } # --- TargetNode --- - It 'Should have TargetNode parameter' { - $script:Cmd.Parameters.ContainsKey('TargetNode') | Should -BeTrue - } - - It 'TargetNode should be Mandatory' { - $isMandatory = $script:Cmd.Parameters['TargetNode'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } It 'TargetNode should be of type String' { $script:Cmd.Parameters['TargetNode'].ParameterType | Should -Be ([string]) @@ -285,12 +165,6 @@ Describe 'Move-PveVm' { Should -Be ([System.Management.Automation.SwitchParameter]) } - It 'Online should not be Mandatory' { - $isMandatory = $script:Cmd.Parameters['Online'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } - # --- Wait (switch, optional) --- It 'Should have Wait switch parameter' { $script:Cmd.Parameters.ContainsKey('Wait') | Should -BeTrue @@ -298,16 +172,7 @@ Describe 'Move-PveVm' { Should -Be ([System.Management.Automation.SwitchParameter]) } - It 'Wait should not be Mandatory' { - $isMandatory = $script:Cmd.Parameters['Wait'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } - # --- Session (inherited) --- - It 'Should have Session parameter (inherited from PveCmdletBase)' { - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } } Context 'ShouldProcess support' { diff --git a/tests/PSProxmoxVE.Tests/Vms/VmConfigCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Vms/VmConfigCmdlets.Tests.ps1 index 2e64127..2a7acce 100644 --- a/tests/PSProxmoxVE.Tests/Vms/VmConfigCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Vms/VmConfigCmdlets.Tests.ps1 @@ -15,33 +15,11 @@ BeforeAll { # Get-PveVmConfig # --------------------------------------------------------------------------- Describe 'Get-PveVmConfig' { - - Context 'Command existence' { - It 'Should be available after module import' { - Get-Command 'Get-PveVmConfig' -ErrorAction SilentlyContinue | - Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - (Get-Command 'Get-PveVmConfig').CommandType | Should -Be 'Cmdlet' - } - } - Context 'Parameter metadata' { BeforeAll { $script:Cmd = Get-Command 'Get-PveVmConfig' } - It 'Should have Node parameter' { - $script:Cmd.Parameters.ContainsKey('Node') | Should -BeTrue - } - - It 'Node should be Mandatory' { - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Node should be of type String' { $script:Cmd.Parameters['Node'].ParameterType | Should -Be ([string]) } @@ -52,16 +30,6 @@ Describe 'Get-PveVmConfig' { $acceptsByPropName | Should -Not -BeNullOrEmpty } - It 'Should have VmId parameter' { - $script:Cmd.Parameters.ContainsKey('VmId') | Should -BeTrue - } - - It 'VmId should be Mandatory' { - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'VmId should be of type Int32' { $script:Cmd.Parameters['VmId'].ParameterType | Should -Be ([int]) } @@ -72,10 +40,6 @@ Describe 'Get-PveVmConfig' { $acceptsByPropName | Should -Not -BeNullOrEmpty } - It 'Should have Session parameter (inherited from PveCmdletBase)' { - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } - It 'Should not support ShouldProcess (read-only cmdlet)' { $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeFalse } @@ -102,49 +66,17 @@ Describe 'Get-PveVmConfig' { # Set-PveVmConfig # --------------------------------------------------------------------------- Describe 'Set-PveVmConfig' { - - Context 'Command existence' { - It 'Should be available after module import' { - Get-Command 'Set-PveVmConfig' -ErrorAction SilentlyContinue | - Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - (Get-Command 'Set-PveVmConfig').CommandType | Should -Be 'Cmdlet' - } - } - Context 'Parameter metadata' { BeforeAll { $script:Cmd = Get-Command 'Set-PveVmConfig' } - It 'Should have Node parameter' { - $script:Cmd.Parameters.ContainsKey('Node') | Should -BeTrue - } - - It 'Node should be Mandatory' { - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Node should accept pipeline input by property name' { $acceptsByPropName = $script:Cmd.Parameters['Node'].ParameterSets.Values | Where-Object { $_.ValueFromPipelineByPropertyName } $acceptsByPropName | Should -Not -BeNullOrEmpty } - It 'Should have VmId parameter' { - $script:Cmd.Parameters.ContainsKey('VmId') | Should -BeTrue - } - - It 'VmId should be Mandatory' { - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'VmId should accept pipeline input by property name' { $acceptsByPropName = $script:Cmd.Parameters['VmId'].ParameterSets.Values | Where-Object { $_.ValueFromPipelineByPropertyName } @@ -227,10 +159,6 @@ Describe 'Set-PveVmConfig' { Where-Object { $_.IsMandatory } $isMandatory | Should -BeNullOrEmpty } - - It 'Should have Session parameter (inherited from PveCmdletBase)' { - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } } Context 'ShouldProcess support' { @@ -276,33 +204,11 @@ Describe 'Set-PveVmConfig' { # Resize-PveVmDisk # --------------------------------------------------------------------------- Describe 'Resize-PveVmDisk' { - - Context 'Command existence' { - It 'Should be available after module import' { - Get-Command 'Resize-PveVmDisk' -ErrorAction SilentlyContinue | - Should -Not -BeNullOrEmpty - } - - It 'Should be a CmdletInfo (binary cmdlet)' { - (Get-Command 'Resize-PveVmDisk').CommandType | Should -Be 'Cmdlet' - } - } - Context 'Parameter metadata' { BeforeAll { $script:Cmd = Get-Command 'Resize-PveVmDisk' } - It 'Should have Node parameter' { - $script:Cmd.Parameters.ContainsKey('Node') | Should -BeTrue - } - - It 'Node should be Mandatory' { - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Node should be of type String' { $script:Cmd.Parameters['Node'].ParameterType | Should -Be ([string]) } @@ -313,16 +219,6 @@ Describe 'Resize-PveVmDisk' { $acceptsByPropName | Should -Not -BeNullOrEmpty } - It 'Should have VmId parameter' { - $script:Cmd.Parameters.ContainsKey('VmId') | Should -BeTrue - } - - It 'VmId should be Mandatory' { - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'VmId should be of type Int32' { $script:Cmd.Parameters['VmId'].ParameterType | Should -Be ([int]) } @@ -333,30 +229,10 @@ Describe 'Resize-PveVmDisk' { $acceptsByPropName | Should -Not -BeNullOrEmpty } - It 'Should have Disk parameter' { - $script:Cmd.Parameters.ContainsKey('Disk') | Should -BeTrue - } - - It 'Disk should be Mandatory' { - $isMandatory = $script:Cmd.Parameters['Disk'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Disk should be of type String' { $script:Cmd.Parameters['Disk'].ParameterType | Should -Be ([string]) } - It 'Should have Size parameter' { - $script:Cmd.Parameters.ContainsKey('Size') | Should -BeTrue - } - - It 'Size should be Mandatory' { - $isMandatory = $script:Cmd.Parameters['Size'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Size should be of type String' { $script:Cmd.Parameters['Size'].ParameterType | Should -Be ([string]) } @@ -366,16 +242,6 @@ Describe 'Resize-PveVmDisk' { $script:Cmd.Parameters['Wait'].ParameterType | Should -Be ([System.Management.Automation.SwitchParameter]) } - - It 'Wait should not be Mandatory' { - $isMandatory = $script:Cmd.Parameters['Wait'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -BeNullOrEmpty - } - - It 'Should have Session parameter (inherited from PveCmdletBase)' { - $script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue - } } Context 'ShouldProcess support' { diff --git a/tests/PSProxmoxVE.Tests/Vms/VmDiskOpsCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Vms/VmDiskOpsCmdlets.Tests.ps1 index f7c7fc3..6c239da 100644 --- a/tests/PSProxmoxVE.Tests/Vms/VmDiskOpsCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Vms/VmDiskOpsCmdlets.Tests.ps1 @@ -5,79 +5,26 @@ Move-PveVmDisk, Remove-PveVmDisk. All tests are fully offline — no live Proxmox VE target is required. - If a cmdlet is not yet compiled the test is marked Skipped. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - $script:Availability = @{} - foreach ($name in @('Move-PveVmDisk', 'Remove-PveVmDisk')) { - $script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue) - } - - function Skip-IfMissing([string]$Name) { - if (-not $script:Availability[$Name]) { - Set-ItResult -Skipped -Because "$Name is not yet implemented in this build" - } - } } # --------------------------------------------------------------------------- # Move-PveVmDisk # --------------------------------------------------------------------------- Describe 'Move-PveVmDisk' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Move-PveVmDisk' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Move-PveVmDisk' - $script:Cmd | Should -Not -BeNullOrEmpty - } - It 'Should be a CmdletInfo (binary cmdlet)' { - Skip-IfMissing 'Move-PveVmDisk' - $script:Cmd.CommandType | Should -Be 'Cmdlet' - } - } + BeforeAll { $script:Cmd = Get-Command 'Move-PveVmDisk' } Context 'ShouldProcess support' { It 'Should support WhatIf' { - Skip-IfMissing 'Move-PveVmDisk' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Move-PveVmDisk' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'VmId should be Mandatory' { - Skip-IfMissing 'Move-PveVmDisk' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Disk should be Mandatory' { - Skip-IfMissing 'Move-PveVmDisk' - $isMandatory = $script:Cmd.Parameters['Disk'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Storage should be Mandatory' { - Skip-IfMissing 'Move-PveVmDisk' - $isMandatory = $script:Cmd.Parameters['Storage'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Move-PveVmDisk' { Move-PveVmDisk -Node 'pve' -VmId 100 -Disk 'scsi0' -Storage 'local-lvm' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } @@ -88,23 +35,13 @@ Describe 'Move-PveVmDisk' -Tag 'Unit' { # Remove-PveVmDisk # --------------------------------------------------------------------------- Describe 'Remove-PveVmDisk' -Tag 'Unit' { - - BeforeAll { $script:Cmd = Get-Command 'Remove-PveVmDisk' -ErrorAction SilentlyContinue } - - Context 'Command existence' { - It 'Should be available after module import' { - Skip-IfMissing 'Remove-PveVmDisk' - $script:Cmd | Should -Not -BeNullOrEmpty - } - } + BeforeAll { $script:Cmd = Get-Command 'Remove-PveVmDisk' } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { - Skip-IfMissing 'Remove-PveVmDisk' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High' { - Skip-IfMissing 'Remove-PveVmDisk' $attr = $script:Cmd.ImplementingType.GetCustomAttributes( [System.Management.Automation.CmdletAttribute], $false) | Select-Object -First 1 @@ -112,30 +49,8 @@ Describe 'Remove-PveVmDisk' -Tag 'Unit' { } } - Context 'Required parameters' { - It 'Node should be Mandatory' { - Skip-IfMissing 'Remove-PveVmDisk' - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'VmId should be Mandatory' { - Skip-IfMissing 'Remove-PveVmDisk' - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'IdList should be Mandatory' { - Skip-IfMissing 'Remove-PveVmDisk' - $isMandatory = $script:Cmd.Parameters['IdList'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - } - Context 'Without active session' { It 'Should throw when no session is active' { - Skip-IfMissing 'Remove-PveVmDisk' { Remove-PveVmDisk -Node 'pve' -VmId 100 -IdList 'scsi0' -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } diff --git a/tests/PSProxmoxVE.Tests/Vms/VmLifecycle.Tests.ps1 b/tests/PSProxmoxVE.Tests/Vms/VmLifecycle.Tests.ps1 index 697ee5b..1f8c985 100644 --- a/tests/PSProxmoxVE.Tests/Vms/VmLifecycle.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Vms/VmLifecycle.Tests.ps1 @@ -6,58 +6,19 @@ Reset-PveVm, Restart-PveVm. All tests are fully offline — no live Proxmox VE target is required. - - NOTE: The C# source declares Reset-PveVm and Restart-PveVm both with - [Cmdlet(VerbsLifecycle.Restart, "PveVm")]. When both are compiled into - the same assembly PowerShell registers the last one loaded as - 'Restart-PveVm'. The test suite validates whichever cmdlet is actually - registered under each name, rather than assuming a specific implementing - type. A separate test records whether 'Reset-PveVm' is resolvable, which - is expected to change once the naming collision is fixed. #> BeforeAll { . $PSScriptRoot/../_TestHelper.ps1 - - # Helper: assert the standard lifecycle parameter set for Node/VmId/Wait. - function Assert-StandardLifecycleParams { - param([string] $CmdletName) - $cmd = Get-Command $CmdletName -ErrorAction SilentlyContinue - if ($null -eq $cmd) { - Set-ItResult -Skipped -Because "$CmdletName is not yet registered (possible name collision in source)" - return $null - } - return $cmd - } } # --------------------------------------------------------------------------- # Start-PveVm # --------------------------------------------------------------------------- Describe 'Start-PveVm' { - - Context 'Command existence' { - It 'Should be available after module import' { - Get-Command 'Start-PveVm' -ErrorAction SilentlyContinue | - Should -Not -BeNullOrEmpty - } - } - Context 'Parameter metadata' { BeforeAll { $script:Cmd = Get-Command 'Start-PveVm' } - It 'Node should be Mandatory' { - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'VmId should be Mandatory' { - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - It 'Should have Wait switch parameter' { $script:Cmd.Parameters.ContainsKey('Wait') | Should -BeTrue $script:Cmd.Parameters['Wait'].ParameterType | @@ -86,33 +47,9 @@ Describe 'Start-PveVm' { # Stop-PveVm # --------------------------------------------------------------------------- Describe 'Stop-PveVm' { - - Context 'Command existence' { - It 'Should be available after module import' { - Get-Command 'Stop-PveVm' -ErrorAction SilentlyContinue | - Should -Not -BeNullOrEmpty - } - } - Context 'Parameter metadata' { BeforeAll { $script:Cmd = Get-Command 'Stop-PveVm' } - It 'Node should be Mandatory' { - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'VmId should be Mandatory' { - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Should have Wait switch parameter' { - $script:Cmd.Parameters.ContainsKey('Wait') | Should -BeTrue - } - It 'Should support ShouldProcess' { $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } @@ -135,33 +72,9 @@ Describe 'Stop-PveVm' { # Suspend-PveVm # --------------------------------------------------------------------------- Describe 'Suspend-PveVm' { - - Context 'Command existence' { - It 'Should be available after module import' { - Get-Command 'Suspend-PveVm' -ErrorAction SilentlyContinue | - Should -Not -BeNullOrEmpty - } - } - Context 'Parameter metadata' { BeforeAll { $script:Cmd = Get-Command 'Suspend-PveVm' } - It 'Node should be Mandatory' { - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'VmId should be Mandatory' { - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Should have Wait switch parameter' { - $script:Cmd.Parameters.ContainsKey('Wait') | Should -BeTrue - } - It 'Should support ShouldProcess' { $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } @@ -186,33 +99,9 @@ Describe 'Suspend-PveVm' { # Resume-PveVm # --------------------------------------------------------------------------- Describe 'Resume-PveVm' { - - Context 'Command existence' { - It 'Should be available after module import' { - Get-Command 'Resume-PveVm' -ErrorAction SilentlyContinue | - Should -Not -BeNullOrEmpty - } - } - Context 'Parameter metadata' { BeforeAll { $script:Cmd = Get-Command 'Resume-PveVm' } - It 'Node should be Mandatory' { - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'VmId should be Mandatory' { - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Should have Wait switch parameter' { - $script:Cmd.Parameters.ContainsKey('Wait') | Should -BeTrue - } - It 'Should support ShouldProcess' { $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } @@ -228,43 +117,14 @@ Describe 'Resume-PveVm' { # --------------------------------------------------------------------------- # Reset-PveVm -# NOTE: Source declares both Reset-PveVmCmdlet and RestartPveVmCmdlet with -# [Cmdlet(VerbsLifecycle.Restart, "PveVm")]. Until the collision is resolved, -# Reset-PveVm may not be separately registered. # --------------------------------------------------------------------------- Describe 'Reset-PveVm' { - - Context 'Command existence' { - It 'Reset-PveVm should be registered in the module exports' { - # Per the .psd1 manifest, 'Reset-PveVm' is listed in CmdletsToExport. - # If the name-collision is present, this may resolve to Restart-PveVm's type. - $cmd = Get-Command 'Reset-PveVm' -ErrorAction SilentlyContinue - $cmd | Should -Not -BeNullOrEmpty - } - } - Context 'Parameter metadata' { BeforeAll { - $script:Cmd = Get-Command 'Reset-PveVm' -ErrorAction SilentlyContinue - } - - It 'Node should be present' { - if ($null -eq $script:Cmd) { Set-ItResult -Skipped -Because 'Reset-PveVm not registered'; return } - $script:Cmd.Parameters.ContainsKey('Node') | Should -BeTrue - } - - It 'VmId should be present' { - if ($null -eq $script:Cmd) { Set-ItResult -Skipped -Because 'Reset-PveVm not registered'; return } - $script:Cmd.Parameters.ContainsKey('VmId') | Should -BeTrue - } - - It 'Wait should be present' { - if ($null -eq $script:Cmd) { Set-ItResult -Skipped -Because 'Reset-PveVm not registered'; return } - $script:Cmd.Parameters.ContainsKey('Wait') | Should -BeTrue + $script:Cmd = Get-Command 'Reset-PveVm' } It 'Should support ShouldProcess' { - if ($null -eq $script:Cmd) { Set-ItResult -Skipped -Because 'Reset-PveVm not registered'; return } $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } @@ -274,33 +134,9 @@ Describe 'Reset-PveVm' { # Restart-PveVm # --------------------------------------------------------------------------- Describe 'Restart-PveVm' { - - Context 'Command existence' { - It 'Should be available after module import' { - Get-Command 'Restart-PveVm' -ErrorAction SilentlyContinue | - Should -Not -BeNullOrEmpty - } - } - Context 'Parameter metadata' { BeforeAll { $script:Cmd = Get-Command 'Restart-PveVm' } - It 'Node should be Mandatory' { - $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'VmId should be Mandatory' { - $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | - Where-Object { $_.IsMandatory } - $isMandatory | Should -Not -BeNullOrEmpty - } - - It 'Should have Timeout parameter' { - $script:Cmd.Parameters.ContainsKey('Timeout') | Should -BeTrue - } - It 'Should have Wait switch parameter' { $script:Cmd.Parameters.ContainsKey('Wait') | Should -BeTrue $script:Cmd.Parameters['Wait'].ParameterType |