Skip to content

Commit

Permalink
[dsccommunity#1474] Added SqlSetup integration tests cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
bozho committed Apr 10, 2020
1 parent 389bece commit 1779587
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/Integration/MSFT_SqlServerLogin.Integration.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,33 @@ try
Test-DscConfiguration -Verbose | Should -Be 'True'
}
}

$configurationName = "$($script:dscResourceName)_CleanupDependencies_Config"

Context ('When using configuration {0}' -f $configurationName) {
It 'Should compile and apply the MOF without throwing' {
{
$configurationParameters = @{
OutputPath = $TestDrive
# The variable $ConfigurationData was dot-sourced above.
ConfigurationData = $ConfigurationData
}

& $configurationName @configurationParameters

$startDscConfigurationParameters = @{
Path = $TestDrive
ComputerName = 'localhost'
Wait = $true
Verbose = $true
Force = $true
ErrorAction = 'Stop'
}

Start-DscConfiguration @startDscConfigurationParameters
} | Should -Not -Throw
}
}
}
}
finally
Expand Down
25 changes: 25 additions & 0 deletions tests/Integration/MSFT_SqlServerLogin.config.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,28 @@ Configuration MSFT_SqlServerLogin_RemoveLoginDscUser3_Config
}
}
}

<#
.SYNOPSIS
Clean up test resources so they are not interfering with
the other integration tests.
#>
Configuration MSFT_SqlServerLogin_CleanupDependencies_Config
{
Import-DscResource -ModuleName 'SqlServerDsc'

node $AllNodes.NodeName
{
SqlDatabase 'Remove_DefaultDb_Test'
{
Ensure = 'Absent'
ServerName = $Node.ServerName
InstanceName = $Node.InstanceName
Name = $Node.DefaultDbName

PsDscRunAsCredential = New-Object `
-TypeName System.Management.Automation.PSCredential `
-ArgumentList @($Node.Admin_UserName, (ConvertTo-SecureString -String $Node.Admin_Password -AsPlainText -Force))
}
}
}

0 comments on commit 1779587

Please sign in to comment.