Skip to content

Commit

Permalink
Update Get-RsRestCacheRefreshPlanHistory.Tests.ps1 (#317)
Browse files Browse the repository at this point in the history
* Update Get-RsRestCacheRefreshPlanHistory.Tests.ps1

Increased Start-Sleep duration from 3 seconds to 6 seconds, to allow time for subscription to run and have history to display.

* Swapped out the Start-Sleep for a While loop.

Swapped out the second Start-Sleep for a While loop.

* Swapped out the other Start-Sleep.

Swapped out the other Start-Sleep.

* Moved break condition for count inside while parens.

Moved break condition for count inside while parens.
  • Loading branch information
SQLvariant authored Feb 6, 2021
1 parent 5c8b3ad commit fbedacb
Showing 1 changed file with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Describe "Get-RsRestCacheRefreshPlanHistory" {
$localPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources'

BeforeEach {
$folderName = 'SUT_WriteRsRestCatalogItem_' + [guid]::NewGuid()
$folderName = 'SUT_GetRsRestCacheRefreshPlanHistory_' + [guid]::NewGuid()
New-RsRestFolder -ReportPortalUri $reportPortalUri -RsFolder / -FolderName $folderName -Verbose
$rsFolderPath = '/' + $folderName
$itemPath = $localPath + '\ReportCatalog.pbix'
Expand All @@ -41,7 +41,7 @@ Describe "Get-RsRestCacheRefreshPlanHistory" {

$dataSources = Get-RsRestItemDataSource -RsItem "$($rsFolderPath)/ReportCatalog" -ReportPortalUri $reportPortalUri
$dataSources[0].DataModelDataSource.AuthType = 'UsernamePassword'
$dataSources[0].DataModelDataSource.Username = 'PBIRS3'
$dataSources[0].DataModelDataSource.Username = 'sa'
$dataSources[0].DataModelDataSource.Secret = 'i<3ReportingServices'
Set-RsRestItemDataSource -RsItem "$($rsFolderPath)/ReportCatalog" -ReportPortalUri $reportPortalUri -DataSources $dataSources -RsItemType 'PowerBIReport'
New-RsRestCacheRefreshPlan -RsItem "$($rsFolderPath)/ReportCatalog" -ReportPortalUri $reportPortalUri -Description 'My New Refresh Plan' -Verbose
Expand All @@ -61,13 +61,23 @@ Describe "Get-RsRestCacheRefreshPlanHistory" {
$plan | Should Not BeNullOrEmpty
$plan.LastStatus | Should Not Be 'New Scheduled Refresh Plan'

Start-Sleep -Seconds 3
$someHistory = Get-RsRestCacheRefreshPlanHistory -ReportPortalUri $reportPortalUri -RsReport "$($rsFolderPath)/ReportCatalog"
$timer= get-date
while ((@($someHistory).count -lt 1)) {
$someHistory = Get-RsRestCacheRefreshPlanHistory -ReportPortalUri $reportPortalUri -RsReport "$($rsFolderPath)/ReportCatalog"
if(((get-date)-$timer).seconds -ge 15) {
break
}
}
@($someHistory).count | Should be 1

Start-RsRestCacheRefreshPlan -ReportPortalUri $reportPortalUri -RsReport "$($rsFolderPath)/ReportCatalog"
Start-Sleep -Seconds 3
$moreHistory = Get-RsRestCacheRefreshPlanHistory -ReportPortalUri $reportPortalUri -RsReport "$($rsFolderPath)/ReportCatalog"
$timer= get-date
while ((@($moreHistory).count -lt 2)) {
$moreHistory = Get-RsRestCacheRefreshPlanHistory -ReportPortalUri $reportPortalUri -RsReport "$($rsFolderPath)/ReportCatalog"
if(((get-date)-$timer).seconds -ge 15) {
break
}
}
@($moreHistory).count | Should be 2
}
}
Expand Down

0 comments on commit fbedacb

Please sign in to comment.