Skip to content

Commit 15d6926

Browse files
committed
Fix connection
1 parent 66a4d34 commit 15d6926

File tree

1 file changed

+6
-20
lines changed

1 file changed

+6
-20
lines changed

tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,14 @@ BeforeAll {
3131

3232
Describe 'Get-SqlDscLogin' -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') {
3333
BeforeAll {
34-
$mockInstanceName = $env:COMPUTERNAME
35-
$mockSqlCredential = $null
36-
$mockConnectTimeout = 30
37-
$mockEncryptConnection = $true
34+
$mockInstanceName = Get-ComputerName
3835

39-
if ($env:INTEGRATION_TESTS_SQLSERVER_CREDENTIAL)
40-
{
41-
<#
42-
This is set by the pipeline so we can run the tests towards the
43-
SQL Server instance on the AppVeyor build worker.
44-
#>
45-
$mockSqlCredential = (ConvertFrom-Json -InputObject $env:INTEGRATION_TESTS_SQLSERVER_CREDENTIAL)
46-
}
36+
$mockSqlAdministratorUserName = 'SqlAdmin' # Using computer name as NetBIOS name throw exception.
37+
$mockSqlAdministratorPassword = ConvertTo-SecureString -String 'P@ssw0rd1' -AsPlainText -Force
4738

48-
try
49-
{
50-
$serverObject = Connect-SqlDscDatabaseEngine -InstanceName $mockInstanceName -Credential $mockSqlCredential -ConnectTimeout $mockConnectTimeout -EncryptConnection $mockEncryptConnection
51-
}
52-
catch
53-
{
54-
Set-ItResult -Skip -Because 'Could not connect to SQL Server instance'
55-
}
39+
$script:mockSqlAdminCredential = [System.Management.Automation.PSCredential]::new($mockSqlAdministratorUserName, $mockSqlAdministratorPassword)
40+
41+
$script:serverObject = Connect-SqlDscDatabaseEngine -InstanceName $script:mockInstanceName -Credential $script:mockSqlAdminCredential
5642
}
5743

5844
Context 'When getting all SQL Server logins' {

0 commit comments

Comments
 (0)