Skip to content

Commit

Permalink
Tests - renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmelton committed May 28, 2021
1 parent 07ffc73 commit 9cb0867
Show file tree
Hide file tree
Showing 41 changed files with 25 additions and 209 deletions.
15 changes: 0 additions & 15 deletions tests/constants.ps1

This file was deleted.

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.
Expand Up @@ -16,31 +16,4 @@ Describe "$commandName Unit Tests" {
$_ | Should -BeNullOrEmpty
}
}
}
Describe "$commandName works" {
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, "version" -join '/'
$restResponse = Invoke-TssRestApi @invokeParams

if (-not $tssTestUsingWindowsAuth) {
$session.SessionExpire()
}
}
Context "Checking" -Foreach @{restResponse = $restResponse} {
It "Should not be empty" {
$restResponse | Should -Not -BeNullOrEmpty
}
It "Should be successful" {
$restResponse.success | Should -BeTrue
}
}
}
25 changes: 25 additions & 0 deletions tests/functions/New-Session.Tests.ps1
@@ -0,0 +1,25 @@
BeforeDiscovery {
$commandName = Split-Path ($PSCommandPath.Replace('.Tests.ps1','')) -Leaf
. ([IO.Path]::Combine([string]$PSScriptRoot, '..', 'constants.ps1'))
}
Describe "$commandName verify parameters" {
BeforeDiscovery {
[object[]]$knownParameters = 'SecretServer', 'Credential', 'AccessToken', 'UseWindowsAuth', 'UseSdkClient', 'ConfigPath'
[object[]]$currentParams = ([Management.Automation.CommandMetaData]$ExecutionContext.SessionState.InvokeCommand.GetCommand($commandName, 'Function')).Parameters.Keys
[object[]]$commandDetails = [System.Management.Automation.CommandInfo]$ExecutionContext.SessionState.InvokeCommand.GetCommand($commandName,'Function')
$unknownParameters = Compare-Object -ReferenceObject $knownParameters -DifferenceObject $currentParams -PassThru
}
Context "Verify parameters" -ForEach @{currentParams = $currentParams } {
It "$commandName should contain <_> parameter" -TestCases $knownParameters {
$_ -in $currentParams | Should -Be $true
}
It "$commandName should not contain parameter: <_>" -TestCases $unknownParameters {
$_ | Should -BeNullOrEmpty
}
}
Context "Command specific details" {
It "$commandName should set OutputType to TssSession" -TestCases $commandDetails {
$_.OutputType.Name | Should -Be 'TssSession'
}
}
}
145 changes: 0 additions & 145 deletions tests/functions/New-TssSession.Tests.ps1

This file was deleted.

Expand Up @@ -22,26 +22,4 @@ Describe "$commandName verify parameters" {
$_.OutputType.Name | Should -Be 'TssVersion'
}
}
}
Describe "$commandName works" {
BeforeDiscovery {
if ($tssTestUsingWindowsAuth) {
$session = New-TssSession -SecretServer $ss -UseWindowsAuth
} else {
$session = New-TssSession -SecretServer $ss -Credential $ssCred
}
$object = Test-TssVersion $session

if (-not $tssTestUsingWindowsAuth) {
$session.SessionExpire()
}
}
Context "Checking" -Foreach @{object = $object} {
It "Should not be empty" {
$object | Should -Not -BeNullOrEmpty
}
It "Should contain property <_>" -TestCases 'Version','LatestVersion','IsLatest' {
$object.PSObject.Properties.Name | Should -Contain $_
}
}
}
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.

0 comments on commit 9cb0867

Please sign in to comment.