diff --git a/Tests/e2e/Snapshot.Tests.ps1 b/Tests/e2e/Snapshot.Tests.ps1 deleted file mode 100644 index 50d40fcd6..000000000 --- a/Tests/e2e/Snapshot.Tests.ps1 +++ /dev/null @@ -1,15 +0,0 @@ -<# -.SYNOPSIS -Run tests around snapshots -#> -BeforeAll { - . "$PSScriptRoot\..\E2eTestInit.ps1" -} - -Describe -Name 'Snapshot Tests' -Fixture { - It -Name 'Get-RscSnapshot' -Test { - # TODO: SPARK-225840 fix this - # $snapshot = Get-RscSnapshot # to do - # $snapshot | Should -Not -BeNullOrEmpty - } -} diff --git a/Toolkit/Public/Get-RscSnapshot.ps1 b/Toolkit/Public/Get-RscSnapshot.ps1 index be95c3bbc..999a673d4 100644 --- a/Toolkit/Public/Get-RscSnapshot.ps1 +++ b/Toolkit/Public/Get-RscSnapshot.ps1 @@ -211,7 +211,7 @@ function Get-RscSnapshot { $cdmSnapshot = $query.field.nodes.FindIndex({param($item) $item.gettype().name -eq "cdmSnapshot"}) $polarisSnapshot = $query.field.nodes.FindIndex({param($item) $item.gettype().name -eq "polarisSnapshot"}) - # Generic fields on both types of snapshots or on generic type + # Generic fields on all types of snapshots $query.field.nodes | ForEach-Object { $_.id = "FETCH" $_.date = "1999-01-01" @@ -229,7 +229,7 @@ function Get-RscSnapshot { $_.isDownloadedSnapshot = $true $_.expiryHint = $true $_.isExpired = $true - $_.parentSnapshotId = "FETCH" + } # Polaris snapshot type @@ -246,6 +246,7 @@ function Get-RscSnapshot { #$query.field.nodes[$polarisSnapshot].replicationLocations[0].id = "FETCH" $query.field.nodes[$polarisSnapshot].hasUnexpiredReplica = $true $query.field.nodes[$polarisSnapshot].hasUnexpiredArchivedCopy = $true + $query.field.nodes[$polarisSnapshot].parentSnapshotId = "FETCH" # CDM snapshot type $query.field.nodes[$cdmSnapshot].isRetentionLocked = $true @@ -291,6 +292,7 @@ function Get-RscSnapshot { $query.field.nodes[$cdmSnapshot].slaDomain.name = "FETCH" $query.field.nodes[$cdmSnapshot].slaDomain.id = "FETCH" $query.field.nodes[$cdmSnapshot].consistencyLevel = [RubrikSecurityCloud.Types.SnapshotConsistencyLevel]::CRASH_CONSISTENT + $query.field.nodes[$cdmSnapshot].parentSnapshotId = "FETCH" $result = Invoke-Rsc -Query $query $result.nodes diff --git a/Toolkit/Tests/e2e/Get-RscSnapshot.Tests.ps1 b/Toolkit/Tests/e2e/Get-RscSnapshot.Tests.ps1 new file mode 100644 index 000000000..37944170b --- /dev/null +++ b/Toolkit/Tests/e2e/Get-RscSnapshot.Tests.ps1 @@ -0,0 +1,33 @@ +BeforeAll { + . "$PSScriptRoot\..\E2eTestInit.ps1" + + # variables shared among tests + $Global:data = @{ + sla = $null + } +} + + +Describe -Name 'Get-RscSnapshot Tests' -Tag 'Public' -Fixture { + + It -Name 'retrieves Snapshots' -Test { + $data.snapshots = Get-RscVmwareVm | Select-Object -first 1 | Get-RscSnapshot + $data.snapshots | Should -Not -BeNullOrEmpty + } + + Context -Name 'Snapshot Count > 0' { + BeforeEach { + # Skip the tests if empty snapshot list + if ($data.snapshots.Count -le 0) { + Set-ItResult -Skipped -Because "At least 1 snapshot is needed" + return + } + } + + It -Name 'retrieves single Snapshot by Id' -Test { + $snapshot = Get-RscSnapshot -Id $data.snapshots[0].id + $snapshot.name | Should -Be $data.snapshots[0].name + $snapshot.id | Should -Be $data.snapshots[0].id + } + } +}