Skip to content

Commit

Permalink
New-TssFolder - removed integration test
Browse files Browse the repository at this point in the history
ToDo - replace with mocking
  • Loading branch information
wsmelton committed Mar 25, 2021
1 parent 8b02968 commit 3ac59d8
Showing 1 changed file with 0 additions and 86 deletions.
86 changes: 0 additions & 86 deletions tests/folders/New-TssFolder.Tests.ps1
Expand Up @@ -22,90 +22,4 @@ Describe "$commandName verify parameters" {
$_.OutputType.Name | Should -Be 'TssFolder'
}
}
}
Describe "$commandName works" -Skip {
BeforeDiscovery {
$invokeParams = @{}
if ($tssTestUsingWindowsAuth) {
$session = New-TssSession -SecretServer $ss -UseWindowsAuth
$invokeParams.UseDefaultCredentials = $true
} else {
$session = New-TssSession -SecretServer $ss -Credential $ssCred
$invokeParams.PersonalAccessToken = $session.AccessToken
}

$invokeParams.Uri = $($session.ApiUrl), "folders?take=$($session.take)" -join '/'
$invokeParams.ExpandProperty = 'records'

$getFolders = Invoke-TssRestApi @invokeParams
$tssSecretFolder = $getFolders.Where( { $_.FolderPath -eq '\tss_module_testing\NewFolder' })

$stub = Get-TssFolderStub -TssSession $session

$testCase = [pscustomobject]@{
FolderName = "tssNewFolder$(Get-Random)"
ParentFolder = $tssSecretFolder.Id
InheritPermissions = $true
}

$newParams = @{
TssSession = $session
FolderStub = $stub
FolderName = $testCase.FolderName
ParentFolderId = $testCase.ParentFolder
InheritPermissions = $testCase.InheritPermissions
}
$newFolder = New-TssFolder @newParams
$createdFolder = Get-TssFolder -TssSession $session -Id $newFolder.Id
$props = 'FolderId', 'FolderName', 'ParentFolderId', 'InheritPermissions'

if (-not $tssTestUsingWindowsAuth) {
$session.SessionExpire()
}
}
Context "Checking" -Foreach @{newFolder = $newFolder } {
It "Should not be empty" {
$newFolder | Should -Not -BeNullOrEmpty
}
It "Should output <_> property" -TestCases $props {
$newFolder.PSObject.Properties.Name | Should -Contain $_
}
}
Context "Validate created folder" -ForEach @{createdFolder = $createdFolder } {
BeforeDiscovery {
$invokeParams = @{}
if ($tssTestUsingWindowsAuth) {
$session = New-TssSession -SecretServer $ss -UseWindowsAuth
$invokeParams.UseDefaultCredentials = $true
} else {
$session = New-TssSession -SecretServer $ss -Credential $ssCred
$invokeParams.PersonalAccessToken = $session.AccessToken
}

$invokeParams.Uri = $($session.ApiUrl), "folders/$($createdFolder.FolderId)" -join '/'
$invokeParams.Method = 'DELETE'
$deletedFolder = Invoke-TssRestApi @invokeParams
if ($deletedFolder.id -ne $createdFolder.FolderId) {
Write-Host "Unable to properly delete created test folder"
}
if (-not $tssTestUsingWindowsAuth) {
$session.SessionExpire()
}
}
It "Should not be empty" {
$createdFolder | Should -Not -BeNullOrEmpty
}
It "Should have set FolderName to <_.FolderName>" -TestCases $testCase {
$createdFolder.FolderName | Should -Be $_.FolderName
}
It "Should not have zero for FolderId" -TestCases $testCase {
$createdFolder.FolderId | Should -Not -Be 0
}
It "Should have ParentFolderId set to <_.ParentFolder>" -TestCases $testCase {
$createdFolder.ParentFolderId | Should -Be $_.ParentFolder
}
It "Should have InheritPermissions set to <_.InheritPermissions>" -TestCases $testCase {
$createdFolder.InheritPermissions | Should -Be $_.InheritPermissions
}
}
}

0 comments on commit 3ac59d8

Please sign in to comment.