diff --git a/ReportingServicesTools/Functions/CatalogItems/Rest/Write-RsRestCatalogItem.ps1 b/ReportingServicesTools/Functions/CatalogItems/Rest/Write-RsRestCatalogItem.ps1 index 1d082281..200b355b 100644 --- a/ReportingServicesTools/Functions/CatalogItems/Rest/Write-RsRestCatalogItem.ps1 +++ b/ReportingServicesTools/Functions/CatalogItems/Rest/Write-RsRestCatalogItem.ps1 @@ -16,6 +16,9 @@ function Write-RsRestCatalogItem .PARAMETER RsFolder Folder on reportserver to upload the item to. + .PARAMETER Description + Specify the description to be added to the report. + .PARAMETER Overwrite Overwrite the old entry, if an existing catalog item with same name exists at the specified destination. @@ -73,6 +76,9 @@ function Write-RsRestCatalogItem [string] $RsFolder, + [string] + $Description, + [Alias('Override')] [switch] $Overwrite, @@ -226,6 +232,7 @@ function Write-RsRestCatalogItem "Content" = [System.Convert]::ToBase64String($bytes); "ContentType"=""; "Name" = $itemName; + "Description" = $Description "Path" = $itemPath; } } diff --git a/ReportingServicesTools/Functions/CatalogItems/Write-RsCatalogItem.ps1 b/ReportingServicesTools/Functions/CatalogItems/Write-RsCatalogItem.ps1 index c62389ad..c0ae1799 100644 --- a/ReportingServicesTools/Functions/CatalogItems/Write-RsCatalogItem.ps1 +++ b/ReportingServicesTools/Functions/CatalogItems/Write-RsCatalogItem.ps1 @@ -10,7 +10,7 @@ function Write-RsCatalogItem .DESCRIPTION Uploads an item from disk to a report server. - Currently, we are only supporting Report, DataSource and DataSet for uploads + Currently, we are only supporting Report, DataSource, DataSet and jpg/png for uploads .PARAMETER Path Path to item to upload on disk. @@ -18,6 +18,9 @@ function Write-RsCatalogItem .PARAMETER RsFolder Folder on reportserver to upload the item to. + .PARAMETER Description + Specify the description to be added to the report. + .PARAMETER Overwrite Overwrite the old entry, if an existing catalog item with same name exists at the specified destination. @@ -52,6 +55,9 @@ function Write-RsCatalogItem [string] $RsFolder, + [string] + $Description, + [Alias('Override')] [switch] $Overwrite, @@ -69,6 +75,8 @@ function Write-RsCatalogItem Begin { $Proxy = New-RsWebServiceProxyHelper -BoundParameters $PSBoundParameters + $namespace = $proxy.GetType().Namespace + $propertyDataType = "$namespace.Property" } Process @@ -86,11 +94,20 @@ function Write-RsCatalogItem $itemType = Get-ItemType $item.Extension $itemName = $item.BaseName - if ($itemType -ne "Report" -and - $itemType -ne "DataSource" -and - $itemType -ne "DataSet") + if ( + ( + $itemType -ne "Report" -and + $itemType -ne "DataSource" -and + $itemType -ne "DataSet" -and + $itemType -ne "Resource" + ) -or + ( + $itemType -eq "Resource" -and + $item.Extension -notin ('.png', '.jpg', '.jpeg') + ) + ) { - throw "Invalid item specified! You can only upload Report, DataSource and DataSet using this command!" + throw "Invalid item specified! You can only upload Report, DataSource, DataSet and jpg/png files using this command!" } if ($RsFolder -eq "/") @@ -187,22 +204,49 @@ function Write-RsCatalogItem #region Upload other stuff else { + $additionalProperties = New-Object System.Collections.Generic.List[$propertyDataType] + $property = New-Object $propertyDataType + + if ($itemType -eq 'Resource') + { + #If it is a resource we need to save the extension so the file can be recognized + $itemName = $item.Name + $property.Name = 'MimeType' + if ($item.Extension -eq ".png") + { + $property.Value = 'image/png' + } + else + { + $property.Value = 'image/jpeg' + } + $erroMessageItemType = 'resource' + } + else + { + $property.Name = 'Description' + $property.Value = $Description + $erroMessageItemType = 'catalog' + } + + $additionalProperties.Add($property) + $bytes = [System.IO.File]::ReadAllBytes($EntirePath) $warnings = $null try { - $Proxy.CreateCatalogItem($itemType, $itemName, $RsFolder, $Overwrite, $bytes, $null, [ref]$warnings) | Out-Null + $Proxy.CreateCatalogItem($itemType, $itemName, $RsFolder, $Overwrite, $bytes, $additionalProperties, [ref]$warnings) | Out-Null if ($warnings) { - foreach ($warn in $warnings) - { - Write-Warning $warn.Message - } + foreach ($warn in $warnings) + { + Write-Warning $warn.Message + } } } catch { - throw (New-Object System.Exception("Failed to create catalog item: $($_.Exception.Message)", $_.Exception)) + throw (New-Object System.Exception("Failed to create $erroMessageItemType item $($item.FullName) : $($_.Exception.Message)", $_.Exception)) } } #endregion Upload other stuff diff --git a/ReportingServicesTools/Functions/CatalogItems/Write-RsFolderContent.ps1 b/ReportingServicesTools/Functions/CatalogItems/Write-RsFolderContent.ps1 index 82d5ec33..1decdbe7 100644 --- a/ReportingServicesTools/Functions/CatalogItems/Write-RsFolderContent.ps1 +++ b/ReportingServicesTools/Functions/CatalogItems/Write-RsFolderContent.ps1 @@ -7,39 +7,39 @@ function Write-RsFolderContent <# .SYNOPSIS Uploads all items in a folder on disk to a report server. - + .DESCRIPTION Uploads all items in a folder on disk to a report server. - Currently, we are only supporting Report, DataSource and DataSet for uploads - + Currently, we are only supporting Report, DataSource, DataSet and jpg/png for uploads + .PARAMETER Recurse A description of the Recurse parameter. - + .PARAMETER Path Path to folder which contains items to upload on disk. - + .PARAMETER RsFolder Folder on reportserver to upload the item to. .PARAMETER Overwrite Overwrite the old entry, if an existing catalog item with same name exists at the specified destination. - + .PARAMETER ReportServerUri Specify the Report Server URL to your SQL Server Reporting Services Instance. Use the "Connect-RsReportServer" function to set/update a default value. - + .PARAMETER Credential Specify the credentials to use when connecting to the Report Server. Use the "Connect-RsReportServer" function to set/update a default value. - + .PARAMETER Proxy Report server proxy to use. Use "New-RsWebServiceProxy" to generate a proxy object for reuse. Useful when repeatedly having to connect to multiple different Report Server. - + .EXAMPLE Write-RsFolderContent -ReportServerUri 'http://localhost/reportserver_sql2012' -Path c:\monthlyreports -RsFolder /monthlyReports - + Description ----------- Uploads all reports under c:\monthlyreports to folder /monthlyReports. @@ -127,12 +127,15 @@ function Write-RsFolderContent if ($item.Extension -eq ".rdl" -or $item.Extension -eq ".rsds" -or $item.Extension -eq ".rsd" -or - $item.Extension -eq ".rds") + $item.Extension -eq ".rds" -or + $item.Extension -eq ".jpg" -or + $item.Extension -eq ".jpeg" -or + $item.Extension -eq ".png" ) { $relativePath = Clear-Substring -string $item.FullName -substring $sourceFolder.FullName.TrimEnd("\") -position front $relativePath = Clear-Substring -string $relativePath -substring ("\" + $item.Name) -position back $relativePath = $relativePath.replace("\", "/") - + if ($RsFolder -eq "/" -and $relativePath -ne "") { $parentFolder = $relativePath diff --git a/Tests/CatalogItems/Rest/Write-RsRestCatalogItem.Tests.ps1 b/Tests/CatalogItems/Rest/Write-RsRestCatalogItem.Tests.ps1 index b190a8e5..d7860912 100644 --- a/Tests/CatalogItems/Rest/Write-RsRestCatalogItem.Tests.ps1 +++ b/Tests/CatalogItems/Rest/Write-RsRestCatalogItem.Tests.ps1 @@ -108,6 +108,18 @@ Describe "Write-RsRestCatalogItem" { Write-RsRestCatalogItem -ReportPortalUri $reportPortalUri -Path $itemPath -RsFolder $rsFolderPath { Write-RsRestCatalogItem -ReportPortalUri $reportPortalUri -Path $itemPath -RsFolder $rsFolderPath -Verbose } | Should Throw } + + It "Should upload a local JPG file" { + $itemPath = $localPath + '\imagesResources\PowerShellHero.jpg' + Write-RsRestCatalogItem -ReportPortalUri $reportPortalUri -Path $itemPath -RsFolder $rsFolderPath -Verbose + VerifyCatalogItemExists -itemName 'PowerShellHero.jpg' -itemType 'Resource' -folderPath $rsFolderPath -reportServerUri $reportServerUri + } + + It "Should upload a local PNG file" { + $itemPath = $localPath + '\imagesResources\SSRS.png' + Write-RsRestCatalogItem -ReportPortalUri $reportPortalUri -Path $itemPath -RsFolder $rsFolderPath -Verbose + VerifyCatalogItemExists -itemName 'SSRS.png' -itemType 'Resource' -folderPath $rsFolderPath -reportServerUri $reportServerUri + } } Context "WebSession parameter" { @@ -167,6 +179,18 @@ Describe "Write-RsRestCatalogItem" { VerifyCatalogItemExists -itemName 'NewKPI' -itemType 'Kpi' -folderPath $rsFolderPath -reportServerUri $reportServerUri } + It "Should upload a local JPG file" { + $itemPath = $localPath + '\imagesResources\PowerShellHero.jpg' + Write-RsRestCatalogItem -WebSession $webSession -Path $itemPath -RsFolder $rsFolderPath -Verbose + VerifyCatalogItemExists -itemName 'PowerShellHero.jpg' -itemType 'Resource' -folderPath $rsFolderPath -reportServerUri $reportServerUri + } + + It "Should upload a local PNG file" { + $itemPath = $localPath + '\imagesResources\SSRS.png' + Write-RsRestCatalogItem -WebSession $webSession -Path $itemPath -RsFolder $rsFolderPath -Verbose + VerifyCatalogItemExists -itemName 'SSRS.png' -itemType 'Resource' -folderPath $rsFolderPath -reportServerUri $reportServerUri + } + It "Should overwrite a file when -Overwrite is specified" { $itemPath = Join-Path -Path $localPath -ChildPath emptyReport.rdl Write-RsRestCatalogItem -WebSession $webSession -Path $itemPath -RsFolder $rsFolderPath diff --git a/Tests/CatalogItems/Write-RsCatalogItem.Tests.ps1 b/Tests/CatalogItems/Write-RsCatalogItem.Tests.ps1 index 474b9fbe..f72ed08b 100644 --- a/Tests/CatalogItems/Write-RsCatalogItem.Tests.ps1 +++ b/Tests/CatalogItems/Write-RsCatalogItem.Tests.ps1 @@ -2,29 +2,30 @@ # Licensed under the MIT License (MIT) Describe "Write-RsCatalogItem" { - + Context "Write-RsCatalogItem with min parameters"{ $folderName = 'SutWriteRsCatalogItem_MinParameters' + [guid]::NewGuid() New-RsFolder -Path / -FolderName $folderName $folderPath = '/' + $folderName $localPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources' - + It "Should upload a local report in Report Server" { - $localReportPath = $localPath + '\emptyReport.rdl' - Write-RsCatalogItem -Path $localReportPath -RsFolder $folderPath + $localReportPath = $localPath + '\emptyReport.rdl' + Write-RsCatalogItem -Path $localReportPath -RsFolder $folderPath -Description 'newDescription' $uploadedReport = (Get-RsFolderContent -RsFolder $folderPath ) | Where-Object TypeName -eq 'Report' $uploadedReport.Name | Should Be 'emptyReport' + $uploadedReport.Description | Should Be 'newDescription' } It "Should upload a local RsDataSource in Report Server" { - $localDataSourcePath = $localPath + '\SutWriteRsFolderContent_DataSource.rsds' + $localDataSourcePath = $localPath + '\SutWriteRsFolderContent_DataSource.rsds' Write-RsCatalogItem -Path $localDataSourcePath -RsFolder $folderPath $uploadedDataSource = (Get-RsFolderContent -RsFolder $folderPath ) | Where-Object TypeName -eq 'DataSource' $uploadedDataSource.Name | Should Be 'SutWriteRsFolderContent_DataSource' } It "Should upload a local DataSet in Report Server" { - $localDataSetPath = $localPath + '\UnDataset.rsd' + $localDataSetPath = $localPath + '\UnDataset.rsd' Write-RsCatalogItem -Path $localDataSetPath -RsFolder $folderPath $uploadedDataSet = (Get-RsFolderContent -RsFolder $folderPath ) | Where-Object TypeName -eq 'DataSet' $uploadedDataSet.Name | Should Be 'UnDataset' @@ -37,13 +38,14 @@ Describe "Write-RsCatalogItem" { $folderName = 'SutWriteRsCatalogItem_ProxyParameter' + [guid]::NewGuid() New-RsFolder -Path / -FolderName $folderName $folderPath = '/' + $folderName - $proxy = New-RsWebServiceProxy - $localReportPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\emptyReport.rdl' - Write-RsCatalogItem -Path $localReportPath -RsFolder $folderPath -Proxy $proxy - + $proxy = New-RsWebServiceProxy + $localReportPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\emptyReport.rdl' + Write-RsCatalogItem -Path $localReportPath -RsFolder $folderPath -Proxy $proxy -Description 'newDescription' + It "Should upload a local Report in ReportServer with Proxy Parameter" { $uploadedReport = (Get-RsFolderContent -RsFolder $folderPath ) | Where-Object TypeName -eq 'Report' $uploadedReport.Name | Should Be 'emptyReport' + $uploadedReport.Description | Should Be 'newDescription' } # Removing folders used for testing Remove-RsCatalogItem -RsFolder $folderPath -Confirm:$false @@ -53,14 +55,15 @@ Describe "Write-RsCatalogItem" { $folderName = 'SutWriteRsCatalogItem_ReporServerUrioProxyParameters' + [guid]::NewGuid() New-RsFolder -Path / -FolderName $folderName $folderPath = '/' + $folderName - $proxy = New-RsWebServiceProxy + $proxy = New-RsWebServiceProxy $reportServerUri = 'http://localhost/reportserver' - $localReportPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\emptyReport.rdl' - Write-RsCatalogItem -Path $localReportPath -RsFolder $folderPath -Proxy $proxy -ReportServerUri $reportServerUri - + $localReportPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\emptyReport.rdl' + Write-RsCatalogItem -Path $localReportPath -RsFolder $folderPath -Proxy $proxy -ReportServerUri $reportServerUri -Description 'newDescription' + It "Should upload a local Report in ReportServer with Proxy and ReportServerUri Parameter" { $uploadedReport = (Get-RsFolderContent -RsFolder $folderPath ) | Where-Object TypeName -eq 'Report' $uploadedReport.Name | Should Be 'emptyReport' + $uploadedReport.Description | Should Be 'newDescription' } # Removing folders used for testing Remove-RsCatalogItem -RsFolder $folderPath -Confirm:$false @@ -71,12 +74,13 @@ Describe "Write-RsCatalogItem" { New-RsFolder -Path / -FolderName $folderName $folderPath = '/' + $folderName $reportServerUri = 'http://localhost/reportserver' - $localReportPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\emptyReport.rdl' - Write-RsCatalogItem -Path $localReportPath -RsFolder $folderPath -ReportServerUri $reportServerUri - + $localReportPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\emptyReport.rdl' + Write-RsCatalogItem -Path $localReportPath -RsFolder $folderPath -ReportServerUri $reportServerUri -Description 'newDescription' + It "Should upload a local Report in ReportServer with ReportServerUri Parameter" { $uploadedReport = (Get-RsFolderContent -RsFolder $folderPath ) | Where-Object TypeName -eq 'Report' $uploadedReport.Name | Should Be 'emptyReport' + $uploadedReport.Description | Should Be 'newDescription' } # Removing folders used for testing Remove-RsCatalogItem -RsFolder $folderPath -Confirm:$false @@ -86,17 +90,51 @@ Describe "Write-RsCatalogItem" { $folderName = 'SutWriteCatalogItem_OverwriteParameter' + [guid]::NewGuid() New-RsFolder -Path / -FolderName $folderName $folderPath = '/' + $folderName - $localReportPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\emptyReport.rdl' - Write-RsCatalogItem -Path $localReportPath -RsFolder $folderPath - $localDataSourcePath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\SutWriteRsFolderContent_DataSource.rsds' - + $localReportPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\emptyReport.rdl' + Write-RsCatalogItem -Path $localReportPath -RsFolder $folderPath -Description 'newDescription' + $localDataSourcePath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\SutWriteRsFolderContent_DataSource.rsds' + It "Should upload a local Report in ReportServer with Overwrite Parameter" { { Write-RsCatalogItem -Path $localReportPath -RsFolder $folderPath } | Should Throw - { Write-RsCatalogItem -Path $localReportPath -RsFolder $folderPath -Overwrite } | Should Not Throw + { Write-RsCatalogItem -Path $localReportPath -RsFolder $folderPath -Overwrite -Description 'overwrittenDescription' } | Should Not Throw $overwrittenReport = (Get-RsFolderContent -RsFolder $folderPath ) | Where-Object TypeName -eq 'Report' $overwrittenReport.Name | Should Be 'emptyReport' + $overwrittenReport.Description | Should Be 'overwrittenDescription' } # Removing folders used for testing Remove-RsCatalogItem -RsFolder $folderPath -Confirm:$false } + + + Context "Write-RsCatalogItem with images"{ + $jpgFolderName = 'SutWriteCatalogItem_JPGimages' + [guid]::NewGuid() + New-RsFolder -Path / -FolderName $jpgFolderName + $jpgFolderPath = '/' + $jpgFolderName + $localJPGImagePath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\imagesResources\PowerShellHero.jpg' + Write-RsCatalogItem -Path $localJPGImagePath -RsFolder $jpgFolderPath + + It "Should upload a local jpg image in ReportServer" { + $jpgImageResource = (Get-RsFolderContent -RsFolder $jpgFolderPath ) | Where-Object TypeName -eq 'Resource' + $jpgImageResource.Name | Should Be 'PowerShellHero.jpg' + $jpgImageResource.ItemMetadata.Name | Should Be 'MIMEType' + $jpgImageResource.ItemMetadata.Value | Should Be 'image/jpeg' + } + + $pngFolderName = 'SutWriteCatalogItem_PNGimages' + [guid]::NewGuid() + New-RsFolder -Path / -FolderName $pngFolderName + $pngFolderPath = '/' + $pngFolderName + $localPNGImagePath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\imagesResources\SSRS.png' + Write-RsCatalogItem -Path $localPNGImagePath -RsFolder $pngFolderPath + + It "Should upload a local png image in ReportServer" { + $jpgImageResource = (Get-RsFolderContent -RsFolder $pngFolderPath ) | Where-Object TypeName -eq 'Resource' + $jpgImageResource.Name | Should Be 'SSRS.png' + $jpgImageResource.ItemMetadata.Name | Should Be 'MIMEType' + $jpgImageResource.ItemMetadata.Value | Should Be 'image/png' + } + + # Removing folders used for testing + Remove-RsCatalogItem -RsFolder $jpgFolderPath -Confirm:$false + Remove-RsCatalogItem -RsFolder $pngFolderPath -Confirm:$false + } } \ No newline at end of file diff --git a/Tests/CatalogItems/Write-RsFolderContent.Tests.ps1 b/Tests/CatalogItems/Write-RsFolderContent.Tests.ps1 index e79ec894..a223863f 100644 --- a/Tests/CatalogItems/Write-RsFolderContent.Tests.ps1 +++ b/Tests/CatalogItems/Write-RsFolderContent.Tests.ps1 @@ -3,13 +3,13 @@ Describe "Write-RsFolderContent" { - Context "Write-RsFolderContent with min parameters"{ + Context "Write-RsFolderContent with min parameters" { $folderName = 'SutWriteRsFolderContentMinParameters' + [guid]::NewGuid() New-RsFolder -Path / -FolderName $folderName $folderPath = '/' + $folderName - $localReportPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources' + $localReportPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources' Write-RsFolderContent -Path $localReportPath -RsFolder $folderPath - + It "Should upload a local report in Report Server" { $uploadedReport = (Get-RsFolderContent -RsFolder $folderPath ) | Where-Object TypeName -eq 'Report' $uploadedReport.Name | Should Be 'emptyReport' @@ -28,11 +28,11 @@ Describe "Write-RsFolderContent" { Remove-RsCatalogItem -RsFolder $folderPath -Confirm:$false } - Context "Write-RsFolderContent with ReportServerUri parameter"{ + Context "Write-RsFolderContent with ReportServerUri parameter" { $folderName = 'SutWriteRsFolderContentReportServerUri' + [guid]::NewGuid() New-RsFolder -Path / -FolderName $folderName $folderPath = '/' + $folderName - $localReportPath = (Get-Item -Path ".\" -Verbose).FullName + '\Tests\CatalogItems\testResources' + $localReportPath = (Get-Item -Path ".\" -Verbose).FullName + '\Tests\CatalogItems\testResources' $reportServerUri = 'http://localhost/reportserver' Write-RsFolderContent -Path $localReportPath -RsFolder $folderPath -ReportServerUri $reportServerUri $uploadedReport = (Get-RsFolderContent -RsFolder $folderPath ) | Where-Object TypeName -eq 'Report' @@ -43,12 +43,12 @@ Describe "Write-RsFolderContent" { Remove-RsCatalogItem -RsFolder $folderPath -Confirm:$false } - Context "Write-RsFolderContent with Proxy Parameter"{ + Context "Write-RsFolderContent with Proxy Parameter" { $folderName = 'SutWriteRsFolderContentProxy' + [guid]::NewGuid() New-RsFolder -Path / -FolderName $folderName $folderPath = '/' + $folderName - $localReportPath = (Get-Item -Path ".\" -Verbose).FullName + '\Tests\CatalogItems\testResources' - $proxy = New-RsWebServiceProxy + $localReportPath = (Get-Item -Path ".\" -Verbose).FullName + '\Tests\CatalogItems\testResources' + $proxy = New-RsWebServiceProxy Write-RsFolderContent -Path $localReportPath -RsFolder $folderPath -Proxy $proxy $uploadedReport = (Get-RsFolderContent -RsFolder $folderPath ) | Where-Object TypeName -eq 'Report' It "Should upload a local report in Report Server with Proxy Parameter" { @@ -58,12 +58,12 @@ Describe "Write-RsFolderContent" { Remove-RsCatalogItem -RsFolder $folderPath -Confirm:$false } - Context "Write-RsFolderContent with Proxy and ReportServerUri"{ + Context "Write-RsFolderContent with Proxy and ReportServerUri" { $folderName = 'SutWriteRsFolderContentAll' + [guid]::NewGuid() New-RsFolder -Path / -FolderName $folderName $folderPath = '/' + $folderName - $localReportPath = (Get-Item -Path ".\" -Verbose).FullName + '\Tests\CatalogItems\testResources' - $proxy = New-RsWebServiceProxy + $localReportPath = (Get-Item -Path ".\" -Verbose).FullName + '\Tests\CatalogItems\testResources' + $proxy = New-RsWebServiceProxy $reportServerUri = 'http://localhost/reportserver' Write-RsFolderContent -Path $localReportPath -RsFolder $folderPath -Proxy $proxy -ReportServerUri $reportServerUri $uploadedReport = (Get-RsFolderContent -RsFolder $folderPath ) | Where-Object TypeName -eq 'Report' @@ -74,17 +74,18 @@ Describe "Write-RsFolderContent" { Remove-RsCatalogItem -RsFolder $folderPath -Confirm:$false } - Context "Write-RsFolderContent with Recurse Parameter"{ + Context "Write-RsFolderContent with Recurse Parameter" { $folderName = 'SutWriteRsFolderContentRecurse' + [guid]::NewGuid() New-RsFolder -Path / -FolderName $folderName $folderPath = '/' + $folderName - $localReportPath = (Get-Item -Path ".\" -Verbose).FullName + '\Tests\CatalogItems\testResources' + $localReportPath = (Get-Item -Path ".\" -Verbose).FullName + '\Tests\CatalogItems\testResources' Write-RsFolderContent -Path $localReportPath -RsFolder $folderPath -Recurse It "Should upload a local subFolder with Recurse Parameter" { $uploadedFolders = (Get-RsFolderContent -RsFolder $folderPath -Recurse ) | Where-Object TypeName -eq 'Folder' | Sort-Object -Property Name -Descending - $uploadedFolders.Count | Should Be 2 + $uploadedFolders.Count | Should Be 3 $uploadedFolders[0].Name | Should Be 'testResources2' - $uploadedFolders[1].Name | Should Be 'datasources' + $uploadedFolders[1].Name | Should Be 'imagesResources' + $uploadedFolders[2].Name | Should Be 'datasources' } It "Should upload a report that is in a folder and a second report that is in a subfolder" { @@ -92,7 +93,7 @@ Describe "Write-RsFolderContent" { $uploadedReports.Count | Should Be 4 } - It "Should upload a local RsDataSource in Report Server" { + It "Should upload a local RsDataSource in Report Server" { $uploadedDataSource = (Get-RsFolderContent -RsFolder $folderPath -Recurse ) | Where-Object TypeName -eq 'DataSource' $uploadedDataSource.Name | Should Be 'SutWriteRsFolderContent_DataSource' } diff --git a/Tests/CatalogItems/testResources/imagesResources/PowerShellHero.jpg b/Tests/CatalogItems/testResources/imagesResources/PowerShellHero.jpg new file mode 100644 index 00000000..f4731dbe Binary files /dev/null and b/Tests/CatalogItems/testResources/imagesResources/PowerShellHero.jpg differ diff --git a/Tests/CatalogItems/testResources/imagesResources/SSRS.png b/Tests/CatalogItems/testResources/imagesResources/SSRS.png new file mode 100644 index 00000000..de401a93 Binary files /dev/null and b/Tests/CatalogItems/testResources/imagesResources/SSRS.png differ