-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow user to copy sample (read-only) files packaged with module (#862)
* Add copy for samples * Update SmokeTest to check support commands * Fix linter errors * Fix linter issues * Remove hardcoded file names
- Loading branch information
1 parent
fe53215
commit c2ae30d
Showing
28 changed files
with
272 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
PowerShell/ScubaGear/Testing/Unit/PowerShell/Support/Copy-ScubaSampleConfigFile.Tests.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
Import-Module (Join-Path -Path $PSScriptRoot -ChildPath "../../../../Modules/Support/Support.psm1") -Function 'Copy-ScubaConfigFile' -Force | ||
|
||
InModuleScope Support { | ||
Describe "Copy sample config files to specified directory" { | ||
$SampleFiles = (Get-ChildItem PowerShell/ScubaGear/Sample-Config-Files).Name | ||
BeforeAll{ | ||
$SampleConfigCopyFolder = Join-Path -Path $env:Temp -ChildPath 'samples/config-files' | ||
if (Test-Path -Path $SampleConfigCopyFolder){ | ||
Remove-Item -Path $SampleConfigCopyFolder -Recurse -Force | ||
} | ||
} | ||
It "Call Copy-ScubaSampleConfigFile with bad destination" { | ||
{Copy-ScubaSampleConfigFile -Destination "$SampleConfigCopyFolder\`tInvalid-"} | | ||
Should -Throw -Because "directory does not exist." | ||
} | ||
It "Call Copy-ScubaSampleConfigFile with good destination"{ | ||
Test-Path -Path $SampleConfigCopyFolder -PathType Container | Should -Not -BeTrue | ||
{Copy-ScubaSampleConfigFile -Destination $SampleConfigCopyFolder} | | ||
Should -Not -Throw | ||
} | ||
It "Top level sample file, <_>, is copied" -ForEach $SampleFiles { | ||
$ItemPath = Join-Path -Path $SampleConfigCopyFolder -ChildPath $_ | ||
Test-Path -Path $ItemPath -PathType Leaf | Should -BeTrue | ||
} | ||
It "Sample document, <_>, is read only" -ForEach $SampleFiles{ | ||
$ItemPath = Join-Path -Path $SampleConfigCopyFolder -ChildPath $_ | ||
Get-Item -Path $ItemPath | Select-Object IsReadyOnly | Should -BeTrue | ||
} | ||
It "Call Copy-ScubaSampleConfigFile already exists - Not Force update"{ | ||
$PreviousCreateTime = [System.DateTime](Get-Item -Path (Join-Path -Path $SampleConfigCopyFolder -ChildPath "aad-config.yaml")).CreationTime | ||
Test-Path -Path $SampleConfigCopyFolder -PathType Container | Should -BeTrue | ||
{Copy-ScubaSampleConfigFile -Destination $SampleConfigCopyFolder} | | ||
Should -Throw -ExpectedMessage "Scuba copy module files failed." | ||
$CurrentCreateTime = [System.DateTime](Get-Item -Path (Join-Path -Path $SampleConfigCopyFolder -ChildPath "aad-config.yaml")).CreationTime | ||
$PreviousCreateTime -eq $CurrentCreateTime | Should -BeTrue | ||
} | ||
It "Call Copy-ScubaSampleConfigFile already exists - Force Update"{ | ||
$PreviousCreateTime = [System.DateTime](Get-Item -Path (Join-Path -Path $SampleConfigCopyFolder -ChildPath "aad-config.yaml")).CreationTime | ||
Test-Path -Path $SampleConfigCopyFolder -PathType Container | Should -BeTrue | ||
{Copy-ScubaSampleConfigFile -Destination $SampleConfigCopyFolder -Force} | | ||
Should -Not -Throw | ||
$CurrentCreateTime = [System.DateTime](Get-Item -Path (Join-Path -Path $SampleConfigCopyFolder -ChildPath "aad-config.yaml")).CreationTime | ||
($CurrentCreateTime -ge $PreviousCreateTime) | Should -BeTrue -Because "$($CurrentCreateTime) vs $($PreviousCreateTime)" | ||
} | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
PowerShell/ScubaGear/Testing/Unit/PowerShell/Support/Copy-ScubaSampleReport.Tests.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
Import-Module (Join-Path -Path $PSScriptRoot -ChildPath "../../../../Modules/Support/Support.psm1") -Function 'Copy-ScubaSampleReport' -Force | ||
|
||
InModuleScope Support { | ||
Describe "Copy Sample Reports to specified directory" { | ||
$SampleFiles = @( | ||
"BaselineReports.html", | ||
"ProviderSettingsExport.json", | ||
"TestResults.csv", | ||
"TestResults.json" | ||
) | ||
$SampleFolders = @( | ||
"individualReports" | ||
"individualReports/images" | ||
) | ||
BeforeAll{ | ||
$SampleReportsCopyFolder = Join-Path -Path $env:Temp -ChildPath 'samples/reports' | ||
if (Test-Path -Path $SampleReportsCopyFolder){ | ||
Remove-Item -Path $SampleReportsCopyFolder -Recurse -Force | ||
} | ||
} | ||
It "Call Copy-ScubaSampleReports with bad destination" { | ||
{Copy-ScubaSampleReport -Destination "$SampleReportsCopyFolder\`tInvalid-"} | | ||
Should -Throw -Because "directory does not exist." | ||
} | ||
It "Call Copy-ScubaSampleReports with good destination"{ | ||
Test-Path -Path $SampleReportsCopyFolder -PathType Container | Should -Not -BeTrue | ||
{Copy-ScubaSampleReport -Destination $SampleReportsCopyFolder} | | ||
Should -Not -Throw | ||
} | ||
It "Top level sample file, <_>, is copied" -ForEach $SampleFiles { | ||
$ItemPath = Join-Path -Path $SampleReportsCopyFolder -ChildPath $_ | ||
Test-Path -Path $ItemPath -PathType Leaf | Should -BeTrue | ||
} | ||
It "Sample sub directory, <_>, is copied" -ForEach $SampleFolders { | ||
$ItemPath = Join-Path -Path $SampleReportsCopyFolder -ChildPath $_ | ||
Test-Path -Path $ItemPath -PathType Container | Should -BeTrue | ||
} | ||
It "Sample document, <_>, is read only" -ForEach $SampleFiles{ | ||
$ItemPath = Join-Path -Path $SampleReportsCopyFolder -ChildPath "$_" | ||
Get-Item -Path $ItemPath | Select-Object IsReadyOnly | Should -BeTrue | ||
} | ||
It "Sample folder, <_>, is read only" -ForEach $SampleFolders{ | ||
$ItemPath = Join-Path -Path $SampleReportsCopyFolder -ChildPath "$_" | ||
Get-Item -Path $ItemPath | Select-Object IsReadyOnly | Should -BeTrue | ||
} | ||
It "Call Copy-ScubaSampleReports already exists - Not Force update"{ | ||
$PreviousCreateTime = [System.DateTime](Get-Item -Path (Join-Path -Path $SampleReportsCopyFolder -ChildPath "BaselineReports.html")).CreationTime | ||
Test-Path -Path $SampleReportsCopyFolder -PathType Container | Should -BeTrue | ||
{Copy-ScubaSampleReport -Destination $SampleReportsCopyFolder} | | ||
Should -Throw -ExpectedMessage "Scuba copy module files failed." | ||
$CurrentCreateTime = [System.DateTime](Get-Item -Path (Join-Path -Path $SampleReportsCopyFolder -ChildPath "BaselineReports.html")).CreationTime | ||
$PreviousCreateTime -eq $CurrentCreateTime | Should -BeTrue | ||
} | ||
It "Call Copy-ScubaSampleReports already exists - Force Update"{ | ||
$PreviousCreateTime = [System.DateTime](Get-Item -Path (Join-Path -Path $SampleReportsCopyFolder -ChildPath "BaselineReports.html")).CreationTime | ||
Test-Path -Path $SampleReportsCopyFolder -PathType Container | Should -BeTrue | ||
{Copy-ScubaSampleReport -Destination $SampleReportsCopyFolder -Force} | | ||
Should -Not -Throw | ||
$CurrentCreateTime = [System.DateTime](Get-Item -Path (Join-Path -Path $SampleReportsCopyFolder -ChildPath "BaselineReports.html")).CreationTime | ||
($CurrentCreateTime -ge $PreviousCreateTime) | Should -BeTrue -Because "$($CurrentCreateTime) vs $($PreviousCreateTime)" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The sample configuration files have been moved into the ScubaGear PowerShell module for easier distribution. The configuration files can now be found [here](../PowerShell/ScubaGear/Sample-Config-Files) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The sample reports have been moved into the ScubaGear PowerShell module for easier distribution. The reports can now be found [here](../PowerShell/ScubaGear/Sample-Reports) |