From 7d850f39caf7762a8254b79a368f19800c7b8bd3 Mon Sep 17 00:00:00 2001 From: andreasjordan Date: Fri, 11 Oct 2024 12:00:29 +0200 Subject: [PATCH 1/2] change variable names (part 1) --- tests/Add-DbaExtendedProperty.Tests.ps1 | 6 ++-- tests/Copy-DbaCredential.Tests.ps1 | 38 ++++++++++---------- tests/Copy-DbaDbAssembly.Tests.ps1 | 20 +++++------ tests/Copy-DbaDbQueryStoreOption.Tests.ps1 | 28 +++++++-------- tests/Get-DbaDbSchema.Tests.ps1 | 38 ++++++++++---------- tests/Get-DbaExtendedProperty.Tests.ps1 | 10 +++--- tests/Get-DbaLinkedServerLogin.Tests.ps1 | 30 ++++++++-------- tests/Get-DbaServerRoleMember.Tests.ps1 | 28 +++++++-------- tests/New-DbaAgentOperator.Tests.ps1 | 18 +++++----- tests/New-DbaDbSchema.Tests.ps1 | 24 ++++++------- tests/Remove-DbaDbSchema.Tests.ps1 | 26 +++++++------- tests/Set-DbaAgentJobStep.Tests.ps1 | 42 +++++++++++----------- tests/Set-DbaDbSchema.Tests.ps1 | 24 ++++++------- tests/Watch-DbaDbLogin.Tests.ps1 | 6 ++-- 14 files changed, 169 insertions(+), 169 deletions(-) diff --git a/tests/Add-DbaExtendedProperty.Tests.ps1 b/tests/Add-DbaExtendedProperty.Tests.ps1 index 4173ff080b..251328389c 100644 --- a/tests/Add-DbaExtendedProperty.Tests.ps1 +++ b/tests/Add-DbaExtendedProperty.Tests.ps1 @@ -16,10 +16,10 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { BeforeAll { $random = Get-Random - $instance2 = Connect-DbaInstance -SqlInstance $script:instance2 - $null = Get-DbaProcess -SqlInstance $instance2 | Where-Object Program -match dbatools | Stop-DbaProcess -Confirm:$false + $server2 = Connect-DbaInstance -SqlInstance $script:instance2 + $null = Get-DbaProcess -SqlInstance $server2 | Where-Object Program -match dbatools | Stop-DbaProcess -Confirm:$false $newDbName = "dbatoolsci_newdb_$random" - $db = New-DbaDatabase -SqlInstance $instance2 -Name $newDbName + $db = New-DbaDatabase -SqlInstance $server2 -Name $newDbName } AfterAll { diff --git a/tests/Copy-DbaCredential.Tests.ps1 b/tests/Copy-DbaCredential.Tests.ps1 index 4cdaaa52a0..326f47ccf1 100644 --- a/tests/Copy-DbaCredential.Tests.ps1 +++ b/tests/Copy-DbaCredential.Tests.ps1 @@ -20,8 +20,8 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { $plaintext = "BigOlPassword!" $password = ConvertTo-SecureString $plaintext -AsPlainText -Force - $instance2 = Connect-DbaInstance -SqlInstance $script:instance2 - $instance3 = Connect-DbaInstance -SqlInstance $script:instance3 + $server2 = Connect-DbaInstance -SqlInstance $script:instance2 + $server3 = Connect-DbaInstance -SqlInstance $script:instance3 # Add user foreach ($login in $logins) { @@ -58,14 +58,14 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { #> # check to see if a crypto provider is present on the instances - $instance2CryptoProviders = $instance2.Query("SELECT name FROM sys.cryptographic_providers WHERE is_enabled = 1 ORDER BY name") - $instance3CryptoProviders = $instance3.Query("SELECT name FROM sys.cryptographic_providers WHERE is_enabled = 1 ORDER BY name") + $instance2CryptoProviders = $server2.Query("SELECT name FROM sys.cryptographic_providers WHERE is_enabled = 1 ORDER BY name") + $instance3CryptoProviders = $server3.Query("SELECT name FROM sys.cryptographic_providers WHERE is_enabled = 1 ORDER BY name") $cryptoProvider = ($instance2CryptoProviders | Where-Object { $_.name -eq $instance3CryptoProviders.name } | Select-Object -First 1).name } AfterAll { - (Get-DbaCredential -SqlInstance $instance2 -Identity dbatoolsci_thor, dbatoolsci_thorsmomma, dbatoolsci_thor_crypto -ErrorAction Stop -WarningAction SilentlyContinue).Drop() - (Get-DbaCredential -SqlInstance $instance3 -Identity dbatoolsci_thor, dbatoolsci_thorsmomma, dbatoolsci_thor_crypto -ErrorAction Stop -WarningAction SilentlyContinue).Drop() + (Get-DbaCredential -SqlInstance $server2 -Identity dbatoolsci_thor, dbatoolsci_thorsmomma, dbatoolsci_thor_crypto -ErrorAction Stop -WarningAction SilentlyContinue).Drop() + (Get-DbaCredential -SqlInstance $server3 -Identity dbatoolsci_thor, dbatoolsci_thorsmomma, dbatoolsci_thor_crypto -ErrorAction Stop -WarningAction SilentlyContinue).Drop() foreach ($login in $logins) { $null = Invoke-Command2 -ScriptBlock { net user $args /delete *>&1 } -ArgumentList $login -ComputerName $script:instance2 @@ -75,16 +75,16 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { Context "Create new credential" { It "Should create new credentials with the proper properties" { - $results = New-DbaCredential -SqlInstance $instance2 -Name dbatoolsci_thorcred -Identity dbatoolsci_thor -Password $password + $results = New-DbaCredential -SqlInstance $server2 -Name dbatoolsci_thorcred -Identity dbatoolsci_thor -Password $password $results.Name | Should Be "dbatoolsci_thorcred" $results.Identity | Should Be "dbatoolsci_thor" - $results = New-DbaCredential -SqlInstance $instance2 -Identity dbatoolsci_thorsmomma -Password $password + $results = New-DbaCredential -SqlInstance $server2 -Identity dbatoolsci_thorsmomma -Password $password $results.Name | Should Be "dbatoolsci_thorsmomma" $results.Identity | Should Be "dbatoolsci_thorsmomma" if ($cryptoProvider) { - $results = New-DbaCredential -SqlInstance $instance2 -Identity dbatoolsci_thor_crypto -Password $password -MappedClassType CryptographicProvider -ProviderName $cryptoProvider + $results = New-DbaCredential -SqlInstance $server2 -Identity dbatoolsci_thor_crypto -Password $password -MappedClassType CryptographicProvider -ProviderName $cryptoProvider $results.Name | Should Be "dbatoolsci_thor_crypto" $results.Identity | Should Be "dbatoolsci_thor_crypto" $results.ProviderName | Should -Be $cryptoProvider @@ -94,13 +94,13 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { Context "Copy Credential with the same properties." { It "Should copy successfully" { - $results = Copy-DbaCredential -Source $instance2 -Destination $instance3 -Name dbatoolsci_thorcred + $results = Copy-DbaCredential -Source $server2 -Destination $server3 -Name dbatoolsci_thorcred $results.Status | Should Be "Successful" } It "Should retain its same properties" { - $Credential1 = Get-DbaCredential -SqlInstance $instance2 -Name dbatoolsci_thor -ErrorAction SilentlyContinue -WarningAction SilentlyContinue - $Credential2 = Get-DbaCredential -SqlInstance $instance3 -Name dbatoolsci_thor -ErrorAction SilentlyContinue -WarningAction SilentlyContinue + $Credential1 = Get-DbaCredential -SqlInstance $server2 -Name dbatoolsci_thor -ErrorAction SilentlyContinue -WarningAction SilentlyContinue + $Credential2 = Get-DbaCredential -SqlInstance $server3 -Name dbatoolsci_thor -ErrorAction SilentlyContinue -WarningAction SilentlyContinue # Compare its value $Credential1.Name | Should Be $Credential2.Name @@ -110,7 +110,7 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { Context "No overwrite" { It "does not overwrite without force" { - $results = Copy-DbaCredential -Source $instance2 -Destination $instance3 -Name dbatoolsci_thorcred + $results = Copy-DbaCredential -Source $server2 -Destination $server3 -Name dbatoolsci_thorcred $results.Status | Should Be "Skipping" } } @@ -118,18 +118,18 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { # See https://github.com/dataplat/dbatools/issues/7896 and comments above in BeforeAll Context "Crypto provider cred" { It -Skip:(-not $cryptoProvider) "ensure copied credential is using the same crypto provider" { - $results = Copy-DbaCredential -Source $instance2 -Destination $instance3 -Name dbatoolsci_thor_crypto + $results = Copy-DbaCredential -Source $server2 -Destination $server3 -Name dbatoolsci_thor_crypto $results.Status | Should Be Successful - $results = Get-DbaCredential -SqlInstance $instance3 -Name dbatoolsci_thor_crypto + $results = Get-DbaCredential -SqlInstance $server3 -Name dbatoolsci_thor_crypto $results.Name | Should -Be dbatoolsci_thor_crypto $results.ProviderName | Should -Be $cryptoProvider } It -Skip:(-not $cryptoProvider) "check warning message if crypto provider is not configured/enabled on destination" { - Remove-DbaCredential -SqlInstance $instance3 -Credential dbatoolsci_thor_crypto -Confirm:$false - $instance3.Query("ALTER CRYPTOGRAPHIC PROVIDER $cryptoProvider DISABLE") - $results = Copy-DbaCredential -Source $instance2 -Destination $instance3 -Name dbatoolsci_thor_crypto - $instance3.Query("ALTER CRYPTOGRAPHIC PROVIDER $cryptoProvider ENABLE") + Remove-DbaCredential -SqlInstance $server3 -Credential dbatoolsci_thor_crypto -Confirm:$false + $server3.Query("ALTER CRYPTOGRAPHIC PROVIDER $cryptoProvider DISABLE") + $results = Copy-DbaCredential -Source $server2 -Destination $server3 -Name dbatoolsci_thor_crypto + $server3.Query("ALTER CRYPTOGRAPHIC PROVIDER $cryptoProvider ENABLE") $results.Status | Should Be Failed $results.Notes | Should -Match "The cryptographic provider $cryptoProvider needs to be configured and enabled on" } diff --git a/tests/Copy-DbaDbAssembly.Tests.ps1 b/tests/Copy-DbaDbAssembly.Tests.ps1 index a2ab7cf804..f0efe59544 100644 --- a/tests/Copy-DbaDbAssembly.Tests.ps1 +++ b/tests/Copy-DbaDbAssembly.Tests.ps1 @@ -15,22 +15,22 @@ Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Describe "$commandname Integration Tests" -Tag "IntegrationTests" { BeforeAll { - $instance3 = Connect-DbaInstance -SqlInstance $script:instance3 - $instance3.Query("CREATE DATABASE dbclrassembly") - $instance3.Query("EXEC sp_configure 'CLR ENABLED' , '1'") - $instance3.Query("RECONFIGURE") + $server3 = Connect-DbaInstance -SqlInstance $script:instance3 + $server3.Query("CREATE DATABASE dbclrassembly") + $server3.Query("EXEC sp_configure 'CLR ENABLED' , '1'") + $server3.Query("RECONFIGURE") - $instance2 = Connect-DbaInstance -SqlInstance $script:instance2 - $instance2.Query("CREATE DATABASE dbclrassembly") - $instance2.Query("EXEC sp_configure 'CLR ENABLED' , '1'") - $instance2.Query("RECONFIGURE") + $server2 = Connect-DbaInstance -SqlInstance $script:instance2 + $server2.Query("CREATE DATABASE dbclrassembly") + $server2.Query("EXEC sp_configure 'CLR ENABLED' , '1'") + $server2.Query("RECONFIGURE") $instance2DB = Get-DbaDatabase -SqlInstance $script:instance2 -Database dbclrassembly $instance2DB.Query("CREATE ASSEMBLY [resolveDNS] AUTHORIZATION [dbo] FROM 0x4D5A90000300000004000000FFFF0000B800000000000000400000000000000000000000000000000000000000000000000000000000000000000000800000000E1FBA0E00B409CD21B8014CCD21546869732070726F6772616D2063616E6E6F742062652072756E20696E20444F53206D6F64652E0D0D0A2400000000000000504500004C010300457830570000000000000000E00002210B010B000008000000060000000000002E260000002000000040000000000010002000000002000004000000000000000400000000000000008000000002000000000000030040850000100000100000000010000010000000000000100000000000000000000000E02500004B00000000400000B002000000000000000000000000000000000000006000000C000000A82400001C0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000080000000000000000000000082000004800000000000000000000002E7465787400000034060000002000000008000000020000000000000000000000000000200000602E72737263000000B00200000040000000040000000A0000000000000000000000000000400000402E72656C6F6300000C0000000060000000020000000E0000000000000000000000000000400000420000000000000000000000000000000010260000000000004800000002000500A42000000404000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001B3001002F000000010000110000026F0500000A280600000A6F0700000A6F0800000A0A06730900000A0BDE0B260002730900000A0BDE0000072A0001100000000001002021000B010000011E02280A00000A2A42534A4201000100000000000C00000076322E302E35303732370000000005006C00000070010000237E0000DC010000A401000023537472696E67730000000080030000080000002355530088030000100000002347554944000000980300006C00000023426C6F620000000000000002000001471502000900000000FA253300160000010000000A0000000200000002000000010000000A0000000400000001000000010000000300000000000A0001000000000006003E0037000A006600510006009D008A000F00B10000000600E000C00006000001C0000A00440129010600590137000E00700165010E007401650100000000010000000000010001000100100019000000050001000100502000000000960070000A0001009C200000000086187D001000020000000100830019007D00140029007D001A0031007D00100039007D00100041006001240049008001280051008D01240009009A01240011007D002E0009007D001000200023001F002E000B0039002E00130042002E001B004B0033000480000000000000000000000000000000001E01000002000000000000000000000001002E00000000000200000000000000000000000100450000000000020000000000000000000000010037000000000000000000003C4D6F64756C653E007265736F6C7665444E532E646C6C0055736572446566696E656446756E6374696F6E73006D73636F726C69620053797374656D004F626A6563740053797374656D2E446174610053797374656D2E446174612E53716C54797065730053716C537472696E67004950746F486F73744E616D65002E63746F72006970616464720053797374656D2E446961676E6F73746963730044656275676761626C6541747472696275746500446562756767696E674D6F6465730053797374656D2E52756E74696D652E436F6D70696C6572536572766963657300436F6D70696C6174696F6E52656C61786174696F6E734174747269627574650052756E74696D65436F6D7061746962696C697479417474726962757465007265736F6C7665444E53004D6963726F736F66742E53716C5365727665722E5365727665720053716C46756E6374696F6E41747472696275746500537472696E67005472696D0053797374656D2E4E657400446E73004950486F7374456E74727900476574486F7374456E747279006765745F486F73744E616D6500546F537472696E6700000003200000000000BBBB2D2F51E12E4791398BFA79459ABA0008B77A5C561934E08905000111090E03200001052001011111042001010804010000000320000E05000112290E042001010E0507020E11090801000701000000000801000800000000001E01000100540216577261704E6F6E457863657074696F6E5468726F7773010000000000004578305700000000020000001C010000C4240000C40600005253445357549849C5462E43AD588F97CA53634201000000633A5C74656D705C4461746162617365315C4461746162617365315C6F626A5C44656275675C7265736F6C7665444E532E706462000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000826000000000000000000001E260000002000000000000000000000000000000000000000000000102600000000000000005F436F72446C6C4D61696E006D73636F7265652E646C6C0000000000FF25002000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100100000001800008000000000000000000000000000000100010000003000008000000000000000000000000000000100000000004800000058400000540200000000000000000000540234000000560053005F00560045005200530049004F004E005F0049004E0046004F0000000000BD04EFFE00000100000000000000000000000000000000003F000000000000000400000002000000000000000000000000000000440000000100560061007200460069006C00650049006E0066006F00000000002400040000005400720061006E0073006C006100740069006F006E00000000000000B004B4010000010053007400720069006E006700460069006C00650049006E0066006F0000009001000001003000300030003000300034006200300000002C0002000100460069006C0065004400650073006300720069007000740069006F006E000000000020000000300008000100460069006C006500560065007200730069006F006E000000000030002E0030002E0030002E003000000040000F00010049006E007400650072006E0061006C004E0061006D00650000007200650073006F006C007600650044004E0053002E0064006C006C00000000002800020001004C006500670061006C0043006F00700079007200690067006800740000002000000048000F0001004F0072006900670069006E0061006C00460069006C0065006E0061006D00650000007200650073006F006C007600650044004E0053002E0064006C006C0000000000340008000100500072006F006400750063007400560065007200730069006F006E00000030002E0030002E0030002E003000000038000800010041007300730065006D0062006C0079002000560065007200730069006F006E00000030002E0030002E0030002E003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000C000000303600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") $hash = $instance2DB.Query("SELECT HASHBYTES('SHA2_512', content) AS SHA2_512 FROM sys.assembly_files WHERE name = 'resolveDNS'") $hexStr = "0x$(($hash.SHA2_512 | ForEach-Object ToString X2) -join '')" - $instance3.Query(" + $server3.Query(" DECLARE @hash VARBINARY(64) = $hexStr , @assemblyName NVARCHAR(4000) = 'resolveDNS'; @@ -41,7 +41,7 @@ Describe "$commandname Integration Tests" -Tag "IntegrationTests" { } AfterAll { Get-DbaDatabase -SqlInstance $script:instance2, $script:instance3 -Database dbclrassembly | Remove-DbaDatabase -Confirm:$false - $instance3.Query(" + $server3.Query(" DECLARE @hash VARBINARY(64) = $hexStr , @assemblyName NVARCHAR(4000) = 'resolveDNS'; diff --git a/tests/Copy-DbaDbQueryStoreOption.Tests.ps1 b/tests/Copy-DbaDbQueryStoreOption.Tests.ps1 index 181cff049f..3ae73a5444 100644 --- a/tests/Copy-DbaDbQueryStoreOption.Tests.ps1 +++ b/tests/Copy-DbaDbQueryStoreOption.Tests.ps1 @@ -16,35 +16,35 @@ Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Describe "$CommandName Integration Tests" -Tags "IntegrationTests" { Context "Verifying query store options are copied" { BeforeAll { - $instance2 = Connect-DbaInstance -SqlInstance $script:instance2 + $server2 = Connect-DbaInstance -SqlInstance $script:instance2 } BeforeEach { $db1Name = "dbatoolsci_querystoretest1" - $db1 = New-DbaDatabase -SqlInstance $instance2 -Name $db1Name + $db1 = New-DbaDatabase -SqlInstance $server2 -Name $db1Name - $db1QSOptions = Get-DbaDbQueryStoreOption -SqlInstance $instance2 -Database $db1Name + $db1QSOptions = Get-DbaDbQueryStoreOption -SqlInstance $server2 -Database $db1Name $originalQSOptionValue = $db1QSOptions.DataFlushIntervalInSeconds $updatedQSOption = $db1QSOptions.DataFlushIntervalInSeconds + 1 - $updatedDB1Options = Set-DbaDbQueryStoreOption -SqlInstance $instance2 -Database $db1Name -FlushInterval $updatedQSOption -State ReadWrite + $updatedDB1Options = Set-DbaDbQueryStoreOption -SqlInstance $server2 -Database $db1Name -FlushInterval $updatedQSOption -State ReadWrite $db2Name = "dbatoolsci_querystoretest2" - $db2 = New-DbaDatabase -SqlInstance $instance2 -Name $db2Name + $db2 = New-DbaDatabase -SqlInstance $server2 -Name $db2Name $db3Name = "dbatoolsci_querystoretest3" - $db3 = New-DbaDatabase -SqlInstance $instance2 -Name $db3Name + $db3 = New-DbaDatabase -SqlInstance $server2 -Name $db3Name $db4Name = "dbatoolsci_querystoretest4" - $db4 = New-DbaDatabase -SqlInstance $instance2 -Name $db4Name + $db4 = New-DbaDatabase -SqlInstance $server2 -Name $db4Name } AfterEach { $db1, $db2, $db3, $db4 | Remove-DbaDatabase -Confirm:$false } It "Copy the query store options from one db to another on the same instance" { - $db2QSOptions = Get-DbaDbQueryStoreOption -SqlInstance $instance2 -Database $db2Name + $db2QSOptions = Get-DbaDbQueryStoreOption -SqlInstance $server2 -Database $db2Name $db2QSOptions.DataFlushIntervalInSeconds | Should -Be $originalQSOptionValue - $result = Copy-DbaDbQueryStoreOption -Source $instance2 -SourceDatabase $db1Name -Destination $instance2 -DestinationDatabase $db2Name + $result = Copy-DbaDbQueryStoreOption -Source $server2 -SourceDatabase $db1Name -Destination $server2 -DestinationDatabase $db2Name $result.Status | Should -Be Successful $result.SourceDatabase | Should -Be $db1Name @@ -52,15 +52,15 @@ Describe "$CommandName Integration Tests" -Tags "IntegrationTests" { $result.Name | Should -Be $db2Name $result.DestinationDatabaseID | Should -Be $db2.ID - $db2QSOptions = Get-DbaDbQueryStoreOption -SqlInstance $instance2 -Database $db2Name + $db2QSOptions = Get-DbaDbQueryStoreOption -SqlInstance $server2 -Database $db2Name $db2QSOptions.DataFlushIntervalInSeconds | Should -Be ($originalQSOptionValue + 1) } It "Apply to all databases except db4" { - $db3QSOptions = Get-DbaDbQueryStoreOption -SqlInstance $instance2 -Database $db3Name + $db3QSOptions = Get-DbaDbQueryStoreOption -SqlInstance $server2 -Database $db3Name $db3QSOptions.DataFlushIntervalInSeconds | Should -Be $originalQSOptionValue - $result = Copy-DbaDbQueryStoreOption -Source $instance2 -SourceDatabase $db1Name -Destination $instance2 -Exclude $db4Name + $result = Copy-DbaDbQueryStoreOption -Source $server2 -SourceDatabase $db1Name -Destination $server2 -Exclude $db4Name $result.Status | Should -Not -Contain 'Failed' $result.Status | Should -Not -Contain 'Skipped' @@ -76,10 +76,10 @@ Describe "$CommandName Integration Tests" -Tags "IntegrationTests" { $result.DestinationDatabaseID | Should -Contain $db2.ID $result.DestinationDatabaseID | Should -Contain $db3.ID - $dbQSOptions = Get-DbaDbQueryStoreOption -SqlInstance $instance2 -Database $db1Name, $db2Name, $db3Name + $dbQSOptions = Get-DbaDbQueryStoreOption -SqlInstance $server2 -Database $db1Name, $db2Name, $db3Name ($dbQSOptions | Where-Object { $_.DataFlushIntervalInSeconds -eq ($originalQSOptionValue + 1) }).Count | Should -Be 3 - $db4QSOptions = Get-DbaDbQueryStoreOption -SqlInstance $instance2 -Database $db4Name + $db4QSOptions = Get-DbaDbQueryStoreOption -SqlInstance $server2 -Database $db4Name $db4QSOptions.DataFlushIntervalInSeconds | Should -Be $originalQSOptionValue } } diff --git a/tests/Get-DbaDbSchema.Tests.ps1 b/tests/Get-DbaDbSchema.Tests.ps1 index 1beebf2a71..7c5835925f 100644 --- a/tests/Get-DbaDbSchema.Tests.ps1 +++ b/tests/Get-DbaDbSchema.Tests.ps1 @@ -16,11 +16,11 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { BeforeAll { $random = Get-Random - $instance1 = Connect-DbaInstance -SqlInstance $script:instance1 - $instance2 = Connect-DbaInstance -SqlInstance $script:instance2 - $null = Get-DbaProcess -SqlInstance $instance1, $instance2 | Where-Object Program -match dbatools | Stop-DbaProcess -Confirm:$false + $server1 = Connect-DbaInstance -SqlInstance $script:instance1 + $server2 = Connect-DbaInstance -SqlInstance $script:instance2 + $null = Get-DbaProcess -SqlInstance $server1, $server2 | Where-Object Program -match dbatools | Stop-DbaProcess -Confirm:$false $newDbName = "dbatoolsci_newdb_$random" - $newDbs = New-DbaDatabase -SqlInstance $instance1, $instance2 -Name $newDbName + $newDbs = New-DbaDatabase -SqlInstance $server1, $server2 -Name $newDbName $schemaName = "TestSchema" $schemaName2 = "TestSchema2" @@ -29,10 +29,10 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { $userName2 = "user2_$random" $password = 'MyV3ry$ecur3P@ssw0rd' $securePassword = ConvertTo-SecureString $password -AsPlainText -Force - $logins = New-DbaLogin -SqlInstance $instance1, $instance2 -Login $userName, $userName2 -Password $securePassword -Force + $logins = New-DbaLogin -SqlInstance $server1, $server2 -Login $userName, $userName2 -Password $securePassword -Force - $null = New-DbaDbUser -SqlInstance $instance1, $instance2 -Database $newDbName -Login $userName - $null = New-DbaDbUser -SqlInstance $instance1, $instance2 -Database $newDbName -Login $userName2 + $null = New-DbaDbUser -SqlInstance $server1, $server2 -Database $newDbName -Login $userName + $null = New-DbaDbUser -SqlInstance $server1, $server2 -Database $newDbName -Login $userName2 $newDbs[0].Query("CREATE SCHEMA $schemaName AUTHORIZATION [$userName]") $newDbs[0].Schemas.Refresh() @@ -48,7 +48,7 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { Context "commands work as expected" { It "get all schemas from all databases including system dbs and schemas" { - $schemas = Get-DbaDbSchema -SqlInstance $instance1 -IncludeSystemDatabases -IncludeSystemSchemas + $schemas = Get-DbaDbSchema -SqlInstance $server1 -IncludeSystemDatabases -IncludeSystemSchemas $schemas.Count | Should -BeGreaterThan 1 $schemas.Parent.Name | Should -Contain master $schemas.Parent.Name | Should -Contain msdb @@ -59,7 +59,7 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { } It "get all schemas from user databases including system schemas" { - $schemas = Get-DbaDbSchema -SqlInstance $instance1 -IncludeSystemSchemas + $schemas = Get-DbaDbSchema -SqlInstance $server1 -IncludeSystemSchemas $schemas.Count | Should -BeGreaterThan 1 $schemas.Parent.Name | Should -Not -Contain master $schemas.Parent.Name | Should -Not -Contain msdb @@ -70,34 +70,34 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { } It "get non-system schemas from a user database" { - $schemas = Get-DbaDbSchema -SqlInstance $instance1 -Schema $schemaName + $schemas = Get-DbaDbSchema -SqlInstance $server1 -Schema $schemaName $schemas.Name | Should -Contain $schemaName $schemas.Parent.Name | Should -Contain $newDbName } It "get a schema by name from a user database" { - $schemas = Get-DbaDbSchema -SqlInstance $instance1 -Database $newDbName -Schema $schemaName + $schemas = Get-DbaDbSchema -SqlInstance $server1 -Database $newDbName -Schema $schemaName $schemas.Count | Should -Be 1 $schemas.Name | Should -Be $schemaName $schemas.DatabaseName | Should -Be $newDbName $schemas.DatabaseId | Should -Be $newDbs[0].Id - $schemas.ComputerName | Should -Be $instance1.ComputerName + $schemas.ComputerName | Should -Be $server1.ComputerName } It "get the dbo schema" { - $schemas = Get-DbaDbSchema -SqlInstance $instance1 -Database $newDbName -Schema dbo -IncludeSystemSchemas + $schemas = Get-DbaDbSchema -SqlInstance $server1 -Database $newDbName -Schema dbo -IncludeSystemSchemas $schemas.Count | Should -Be 1 $schemas.Name | Should -Be dbo } It "get schemas by owner from a user database" { - $schemas = Get-DbaDbSchema -SqlInstance $instance1 -SchemaOwner $userName + $schemas = Get-DbaDbSchema -SqlInstance $server1 -SchemaOwner $userName $schemas.Count | Should -Be 1 $schemas.Name | Should -Be $schemaName $schemas.Owner | Should -Be $userName $schemas.Parent.Name | Should -Be $newDbName - $schemas = Get-DbaDbSchema -SqlInstance $instance1, $instance2 -Database $newDbName -SchemaOwner $userName, $userName2 + $schemas = Get-DbaDbSchema -SqlInstance $server1, $server2 -Database $newDbName -SchemaOwner $userName, $userName2 $schemas.Count | Should -Be 2 $schemas.Name | Should -Be $schemaName, $schemaName2 $schemas.Owner | Should -Be $userName, $userName2 @@ -113,26 +113,26 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { } It "get a schema and then change the owner" { - $schemas = Get-DbaDbSchema -SqlInstance $instance1 -Database $newDbName -Schema $schemaName + $schemas = Get-DbaDbSchema -SqlInstance $server1 -Database $newDbName -Schema $schemaName $schemas.Count | Should -Be 1 $schemas.Owner | Should -Be $userName $schemas.Owner = $userName2 $schemas.Alter() - $schemas = Get-DbaDbSchema -SqlInstance $instance1 -Database $newDbName -Schema $schemaName + $schemas = Get-DbaDbSchema -SqlInstance $server1 -Database $newDbName -Schema $schemaName $schemas.Count | Should -Be 1 $schemas.Owner | Should -Be $userName2 } It "get a schema and then drop it (assuming that it does not contain any objects)" { - $schemas = Get-DbaDbSchema -SqlInstance $instance2 -Database $newDbName -Schema $schemaName2 + $schemas = Get-DbaDbSchema -SqlInstance $server2 -Database $newDbName -Schema $schemaName2 $schemas.Count | Should -Be 1 $schemas.Owner | Should -Be $userName2 $schemas.Drop() - $schemas = Get-DbaDbSchema -SqlInstance $instance2 -Database $newDbName -Schema $schemaName2 + $schemas = Get-DbaDbSchema -SqlInstance $server2 -Database $newDbName -Schema $schemaName2 $schemas | Should -BeNullOrEmpty } } diff --git a/tests/Get-DbaExtendedProperty.Tests.ps1 b/tests/Get-DbaExtendedProperty.Tests.ps1 index a362171c38..d9fa10d14f 100644 --- a/tests/Get-DbaExtendedProperty.Tests.ps1 +++ b/tests/Get-DbaExtendedProperty.Tests.ps1 @@ -16,10 +16,10 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { BeforeAll { $random = Get-Random - $instance2 = Connect-DbaInstance -SqlInstance $script:instance2 - $null = Get-DbaProcess -SqlInstance $instance2 | Where-Object Program -match dbatools | Stop-DbaProcess -Confirm:$false + $server2 = Connect-DbaInstance -SqlInstance $script:instance2 + $null = Get-DbaProcess -SqlInstance $server2 | Where-Object Program -match dbatools | Stop-DbaProcess -Confirm:$false $newDbName = "dbatoolsci_newdb_$random" - $db = New-DbaDatabase -SqlInstance $instance2 -Name $newDbName + $db = New-DbaDatabase -SqlInstance $server2 -Name $newDbName $db.Query("EXEC sys.sp_addextendedproperty @name=N'dbatoolz', @value=N'woo'") #$tempdb = Get-DbaDatabase -SqlInstance $script:instance2 -Database tempdb #$tempdb.Query("EXEC sys.sp_addextendedproperty @name=N'temptoolz', @value=N'woo2'") @@ -32,12 +32,12 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { Context "commands work as expected" { It "finds an extended property on an instance" { - $ep = Get-DbaExtendedProperty -SqlInstance $instance2 + $ep = Get-DbaExtendedProperty -SqlInstance $server2 $ep.Count | Should -BeGreaterThan 0 } It "finds a sequence in a single database" { - $ep = Get-DbaExtendedProperty -SqlInstance $instance2 -Database $db.Name + $ep = Get-DbaExtendedProperty -SqlInstance $server2 -Database $db.Name $ep.Parent.Name | Select-Object -Unique | Should -Be $db.Name $ep.Count | Should -Be 1 } diff --git a/tests/Get-DbaLinkedServerLogin.Tests.ps1 b/tests/Get-DbaLinkedServerLogin.Tests.ps1 index 772e2e411a..62abe23774 100644 --- a/tests/Get-DbaLinkedServerLogin.Tests.ps1 +++ b/tests/Get-DbaLinkedServerLogin.Tests.ps1 @@ -16,8 +16,8 @@ Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Describe "$commandname Integration Tests" -Tags "IntegrationTests" { BeforeAll { $random = Get-Random - $instance2 = Connect-DbaInstance -SqlInstance $script:instance2 - $instance3 = Connect-DbaInstance -SqlInstance $script:instance3 + $server2 = Connect-DbaInstance -SqlInstance $script:instance2 + $server3 = Connect-DbaInstance -SqlInstance $script:instance3 $securePassword = ConvertTo-SecureString -String 's3cur3P4ssw0rd?' -AsPlainText -Force $localLogin1Name = "dbatoolscli_localLogin1_$random" @@ -27,11 +27,11 @@ Describe "$commandname Integration Tests" -Tags "IntegrationTests" { $linkedServer1Name = "dbatoolscli_linkedServer1_$random" $linkedServer2Name = "dbatoolscli_linkedServer2_$random" - New-DbaLogin -SqlInstance $instance2 -Login $localLogin1Name, $localLogin2Name -SecurePassword $securePassword - New-DbaLogin -SqlInstance $instance3 -Login $remoteLoginName -SecurePassword $securePassword + New-DbaLogin -SqlInstance $server2 -Login $localLogin1Name, $localLogin2Name -SecurePassword $securePassword + New-DbaLogin -SqlInstance $server3 -Login $remoteLoginName -SecurePassword $securePassword - $linkedServer1 = New-DbaLinkedServer -SqlInstance $instance2 -LinkedServer $linkedServer1Name -ServerProduct mssql -Provider sqlncli -DataSource $instance3 - $linkedServer2 = New-DbaLinkedServer -SqlInstance $instance2 -LinkedServer $linkedServer2Name -ServerProduct mssql -Provider sqlncli -DataSource $instance3 + $linkedServer1 = New-DbaLinkedServer -SqlInstance $server2 -LinkedServer $linkedServer1Name -ServerProduct mssql -Provider sqlncli -DataSource $server3 + $linkedServer2 = New-DbaLinkedServer -SqlInstance $server2 -LinkedServer $linkedServer2Name -ServerProduct mssql -Provider sqlncli -DataSource $server3 $newLinkedServerLogin1 = New-Object Microsoft.SqlServer.Management.Smo.LinkedServerLogin $newLinkedServerLogin1.Parent = $linkedServer1 @@ -58,27 +58,27 @@ Describe "$commandname Integration Tests" -Tags "IntegrationTests" { $newLinkedServerLogin3.Create() } AfterAll { - Remove-DbaLinkedServer -SqlInstance $instance2 -LinkedServer $linkedServer1Name, $linkedServer2Name -Confirm:$false -Force - Remove-DbaLogin -SqlInstance $instance2 -Login $localLogin1Name, $localLogin2Name -Confirm:$false - Remove-DbaLogin -SqlInstance $instance3 -Login $remoteLoginName -Confirm:$false + Remove-DbaLinkedServer -SqlInstance $server2 -LinkedServer $linkedServer1Name, $linkedServer2Name -Confirm:$false -Force + Remove-DbaLogin -SqlInstance $server2 -Login $localLogin1Name, $localLogin2Name -Confirm:$false + Remove-DbaLogin -SqlInstance $server3 -Login $remoteLoginName -Confirm:$false } Context "ensure command works" { It "Check the validation for a linked server" { - $results = Get-DbaLinkedServerLogin -SqlInstance $instance2 -LocalLogin $localLogin1Name -WarningVariable warnings 3> $null + $results = Get-DbaLinkedServerLogin -SqlInstance $server2 -LocalLogin $localLogin1Name -WarningVariable warnings 3> $null $warnings | Should -BeLike "*LinkedServer is required*" $results | Should -BeNullOrEmpty } It "Get a linked server login" { - $results = Get-DbaLinkedServerLogin -SqlInstance $instance2 -LinkedServer $linkedServer1Name -LocalLogin $localLogin1Name + $results = Get-DbaLinkedServerLogin -SqlInstance $server2 -LinkedServer $linkedServer1Name -LocalLogin $localLogin1Name $results | Should -Not -BeNullOrEmpty $results.Name | Should -Be $localLogin1Name $results.RemoteUser | Should -Be $remoteLoginName $results.Impersonate | Should -Be $false - $results = Get-DbaLinkedServerLogin -SqlInstance $instance2 -LinkedServer $linkedServer1Name -LocalLogin $localLogin1Name, $localLogin2Name + $results = Get-DbaLinkedServerLogin -SqlInstance $server2 -LinkedServer $linkedServer1Name -LocalLogin $localLogin1Name, $localLogin2Name $results.length | Should -Be 2 $results.Name | Should -Be $localLogin1Name, $localLogin2Name $results.RemoteUser | Should -Be $remoteLoginName, $remoteLoginName @@ -86,14 +86,14 @@ Describe "$commandname Integration Tests" -Tags "IntegrationTests" { } It "Get a linked server login and exclude a login" { - $results = Get-DbaLinkedServerLogin -SqlInstance $instance2 -LinkedServer $linkedServer1Name -ExcludeLocalLogin $localLogin1Name + $results = Get-DbaLinkedServerLogin -SqlInstance $server2 -LinkedServer $linkedServer1Name -ExcludeLocalLogin $localLogin1Name $results | Should -Not -BeNullOrEmpty $results.Name | Should -Contain $localLogin2Name $results.Name | Should -Not -Contain $localLogin1Name } It "Get a linked server login by passing in a server via pipeline" { - $results = $instance2 | Get-DbaLinkedServerLogin -LinkedServer $linkedServer1Name -LocalLogin $localLogin1Name + $results = $server2 | Get-DbaLinkedServerLogin -LinkedServer $linkedServer1Name -LocalLogin $localLogin1Name $results | Should -Not -BeNullOrEmpty $results.Name | Should -Be $localLogin1Name } @@ -105,7 +105,7 @@ Describe "$commandname Integration Tests" -Tags "IntegrationTests" { } It "Get a linked server login from multiple linked servers" { - $results = Get-DbaLinkedServerLogin -SqlInstance $instance2 -LinkedServer $linkedServer1Name, $linkedServer2Name -LocalLogin $localLogin1Name + $results = Get-DbaLinkedServerLogin -SqlInstance $server2 -LinkedServer $linkedServer1Name, $linkedServer2Name -LocalLogin $localLogin1Name $results | Should -Not -BeNullOrEmpty $results.Name | Should -Be $localLogin1Name, $localLogin1Name } diff --git a/tests/Get-DbaServerRoleMember.Tests.ps1 b/tests/Get-DbaServerRoleMember.Tests.ps1 index 1660ce4614..0f35bd6178 100644 --- a/tests/Get-DbaServerRoleMember.Tests.ps1 +++ b/tests/Get-DbaServerRoleMember.Tests.ps1 @@ -15,35 +15,35 @@ Describe "$CommandName Unit Tests" -Tags "UnitTests" { Describe "$CommandName Integration Tests" -Tags "IntegrationTests" { BeforeAll { - $instance = Connect-DbaInstance -SqlInstance $script:instance2 + $server2 = Connect-DbaInstance -SqlInstance $script:instance2 $password1 = ConvertTo-SecureString 'password1' -AsPlainText -Force $testLogin = 'getDbaInstanceRoleMemberLogin' - $null = New-DbaLogin -SqlInstance $instance -Login $testLogin -Password $password1 - $null = Set-DbaLogin -SqlInstance $instance -Login $testLogin -AddRole 'dbcreator' + $null = New-DbaLogin -SqlInstance $server2 -Login $testLogin -Password $password1 + $null = Set-DbaLogin -SqlInstance $server2 -Login $testLogin -AddRole 'dbcreator' - $instance1 = Connect-DbaInstance -SqlInstance $script:instance1 - $null = New-DbaLogin -SqlInstance $instance1 -Login $testLogin -Password $password1 - $null = Set-DbaLogin -SqlInstance $instance1 -Login $testLogin -AddRole 'dbcreator' + $server1 = Connect-DbaInstance -SqlInstance $script:instance1 + $null = New-DbaLogin -SqlInstance $server1 -Login $testLogin -Password $password1 + $null = Set-DbaLogin -SqlInstance $server1 -Login $testLogin -AddRole 'dbcreator' } Context "Functionality" { It 'Returns all role membership for server roles' { - $result = Get-DbaServerRoleMember -SqlInstance $instance + $result = Get-DbaServerRoleMember -SqlInstance $server2 # should have at least $testLogin and a sysadmin $result.Count | Should -BeGreaterOrEqual 2 } It 'Accepts a list of roles' { - $result = Get-DbaServerRoleMember -SqlInstance $instance -ServerRole 'sysadmin' + $result = Get-DbaServerRoleMember -SqlInstance $server2 -ServerRole 'sysadmin' $uniqueRoles = $result.Role | Select-Object -Unique $uniqueRoles | Should -Be 'sysadmin' } It 'Excludes roles' { - $result = Get-DbaServerRoleMember -SqlInstance $instance -ExcludeServerRole 'dbcreator' + $result = Get-DbaServerRoleMember -SqlInstance $server2 -ExcludeServerRole 'dbcreator' $uniqueRoles = $result.Role | Select-Object -Unique $uniqueRoles | Should -Not -Contain 'dbcreator' @@ -51,13 +51,13 @@ Describe "$CommandName Integration Tests" -Tags "IntegrationTests" { } It 'Excludes fixed roles' { - $result = Get-DbaServerRoleMember -SqlInstance $instance -ExcludeFixedRole + $result = Get-DbaServerRoleMember -SqlInstance $server2 -ExcludeFixedRole $uniqueRoles = $result.Role | Select-Object -Unique $uniqueRoles | Should -Not -Contain 'sysadmin' } It 'Filters by a specific login' { - $result = Get-DbaServerRoleMember -SqlInstance $instance -Login $testLogin + $result = Get-DbaServerRoleMember -SqlInstance $server2 -Login $testLogin $uniqueLogins = $result.Name | Select-Object -Unique $uniqueLogins.Count | Should -BeExactly 1 @@ -65,7 +65,7 @@ Describe "$CommandName Integration Tests" -Tags "IntegrationTests" { } It 'Returns results for all instances' { - $result = Get-DbaServerRoleMember -SqlInstance $instance, $instance1 -Login $testLogin + $result = Get-DbaServerRoleMember -SqlInstance $server2, $server1 -Login $testLogin $uniqueInstances = $result.SqlInstance | Select-Object -Unique $uniqueInstances.Count | Should -BeExactly 2 @@ -73,7 +73,7 @@ Describe "$CommandName Integration Tests" -Tags "IntegrationTests" { } AfterAll { - Remove-DbaLogin -SqlInstance $instance -Login $testLogin -Force -Confirm:$false - Remove-DbaLogin -SqlInstance $instance1 -Login $testLogin -Force -Confirm:$false + Remove-DbaLogin -SqlInstance $server2 -Login $testLogin -Force -Confirm:$false + Remove-DbaLogin -SqlInstance $server1 -Login $testLogin -Force -Confirm:$false } } \ No newline at end of file diff --git a/tests/New-DbaAgentOperator.Tests.ps1 b/tests/New-DbaAgentOperator.Tests.ps1 index 2197fff524..bc6fce76a2 100644 --- a/tests/New-DbaAgentOperator.Tests.ps1 +++ b/tests/New-DbaAgentOperator.Tests.ps1 @@ -15,7 +15,7 @@ Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Describe "$CommandName Integration Tests" -Tags "IntegrationTests" { BeforeAll { $random = Get-Random - $instance2 = Connect-DbaInstance -SqlInstance $script:instance2 + $server2 = Connect-DbaInstance -SqlInstance $script:instance2 $email1 = "test1$($random)@test.com" $email2 = "test2$($random)@test.com" $email3 = "test3$($random)@test.com" @@ -23,31 +23,31 @@ Describe "$CommandName Integration Tests" -Tags "IntegrationTests" { } AfterAll { - $null = Remove-DbaAgentOperator -SqlInstance $instance2 -Operator $email1 -Confirm:$false - $null = Remove-DbaAgentOperator -SqlInstance $instance2 -Operator $email2 -Confirm:$false - $null = Remove-DbaAgentOperator -SqlInstance $instance2 -Operator $email3 -Confirm:$false - $null = Remove-DbaAgentOperator -SqlInstance $instance2 -Operator $email4 -Confirm:$false + $null = Remove-DbaAgentOperator -SqlInstance $server2 -Operator $email1 -Confirm:$false + $null = Remove-DbaAgentOperator -SqlInstance $server2 -Operator $email2 -Confirm:$false + $null = Remove-DbaAgentOperator -SqlInstance $server2 -Operator $email3 -Confirm:$false + $null = Remove-DbaAgentOperator -SqlInstance $server2 -Operator $email4 -Confirm:$false } Context "New Agent Operator is added properly" { It "Should have the right name" { - $results = New-DbaAgentOperator -SqlInstance $instance2 -Operator $email1 -EmailAddress $email1 -PagerDay Everyday -Force + $results = New-DbaAgentOperator -SqlInstance $server2 -Operator $email1 -EmailAddress $email1 -PagerDay Everyday -Force $results.Name | Should Be $email1 } It "Create an agent operator with only the defaults" { - $results = New-DbaAgentOperator -SqlInstance $instance2 -Operator $email2 -EmailAddress $email2 + $results = New-DbaAgentOperator -SqlInstance $server2 -Operator $email2 -EmailAddress $email2 $results.Name | Should Be $email2 } It "Pipeline command" { - $results = $instance2 | New-DbaAgentOperator -Operator $email3 -EmailAddress $email3 + $results = $server2 | New-DbaAgentOperator -Operator $email3 -EmailAddress $email3 $results.Name | Should Be $email3 } It "Creates an agent operator with all params" { - $results = New-DbaAgentOperator -SqlInstance $instance2 -Operator $email4 -EmailAddress $email4 -NetSendAddress dbauser1 -PagerAddress dbauser1@pager.dbatools.io -PagerDay Everyday -SaturdayStartTime 070000 -SaturdayEndTime 180000 -SundayStartTime 080000 -SundayEndTime 170000 -WeekdayStartTime 060000 -WeekdayEndTime 190000 + $results = New-DbaAgentOperator -SqlInstance $server2 -Operator $email4 -EmailAddress $email4 -NetSendAddress dbauser1 -PagerAddress dbauser1@pager.dbatools.io -PagerDay Everyday -SaturdayStartTime 070000 -SaturdayEndTime 180000 -SundayStartTime 080000 -SundayEndTime 170000 -WeekdayStartTime 060000 -WeekdayEndTime 190000 $results.Enabled | Should -Be $true $results.Name | Should Be $email4 $results.EmailAddress | Should -Be $email4 diff --git a/tests/New-DbaDbSchema.Tests.ps1 b/tests/New-DbaDbSchema.Tests.ps1 index 39734bf7f0..abef66b323 100644 --- a/tests/New-DbaDbSchema.Tests.ps1 +++ b/tests/New-DbaDbSchema.Tests.ps1 @@ -16,18 +16,18 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { BeforeAll { $random = Get-Random - $instance1 = Connect-DbaInstance -SqlInstance $script:instance1 - $instance2 = Connect-DbaInstance -SqlInstance $script:instance2 - $null = Get-DbaProcess -SqlInstance $instance1, $instance2 | Where-Object Program -match dbatools | Stop-DbaProcess -Confirm:$false + $server1 = Connect-DbaInstance -SqlInstance $script:instance1 + $server2 = Connect-DbaInstance -SqlInstance $script:instance2 + $null = Get-DbaProcess -SqlInstance $server1, $server2 | Where-Object Program -match dbatools | Stop-DbaProcess -Confirm:$false $newDbName = "dbatoolsci_newdb_$random" - $newDbs = New-DbaDatabase -SqlInstance $instance1, $instance2 -Name $newDbName + $newDbs = New-DbaDatabase -SqlInstance $server1, $server2 -Name $newDbName $userName = "user_$random" $password = 'MyV3ry$ecur3P@ssw0rd' $securePassword = ConvertTo-SecureString $password -AsPlainText -Force - $logins = New-DbaLogin -SqlInstance $instance1, $instance2 -Login $userName -Password $securePassword -Force + $logins = New-DbaLogin -SqlInstance $server1, $server2 -Login $userName -Password $securePassword -Force - $null = New-DbaDbUser -SqlInstance $instance1, $instance2 -Database $newDbName -Login $userName + $null = New-DbaDbUser -SqlInstance $server1, $server2 -Database $newDbName -Login $userName } AfterAll { @@ -38,23 +38,23 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { Context "commands work as expected" { It "validates required Schema" { - $schema = New-DbaDbSchema -SqlInstance $instance1 + $schema = New-DbaDbSchema -SqlInstance $server1 $schema | Should -BeNullOrEmpty } It "validates required Database param" { - $schema = New-DbaDbSchema -SqlInstance $instance1 -Schema TestSchema1 + $schema = New-DbaDbSchema -SqlInstance $server1 -Schema TestSchema1 $schema | Should -BeNullOrEmpty } It "creates a new schema" { - $schema = New-DbaDbSchema -SqlInstance $instance1 -Database $newDbName -Schema TestSchema1 -SchemaOwner $userName + $schema = New-DbaDbSchema -SqlInstance $server1 -Database $newDbName -Schema TestSchema1 -SchemaOwner $userName $schema.Count | Should -Be 1 $schema.Owner | Should -Be $userName $schema.Name | Should -Be TestSchema1 $schema.Parent.Name | Should -Be $newDbName - $schemas = New-DbaDbSchema -SqlInstance $instance1, $instance2 -Database $newDbName -Schema TestSchema2, TestSchema3 -SchemaOwner $userName + $schemas = New-DbaDbSchema -SqlInstance $server1, $server2 -Database $newDbName -Schema TestSchema2, TestSchema3 -SchemaOwner $userName $schemas.Count | Should -Be 4 $schemas.Owner | Should -Be $userName, $userName, $userName, $userName $schemas.Name | Should -Be TestSchema2, TestSchema3, TestSchema2, TestSchema3 @@ -62,12 +62,12 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { } It "reports a warning that the schema already exists" { - $schema = New-DbaDbSchema -SqlInstance $instance1 -Database $newDbName -Schema TestSchema1 -SchemaOwner $userName + $schema = New-DbaDbSchema -SqlInstance $server1 -Database $newDbName -Schema TestSchema1 -SchemaOwner $userName $schema | Should -BeNullOrEmpty } It "supports piping databases" { - $schema = Get-DbaDatabase -SqlInstance $instance1 -Database $newDbName | New-DbaDbSchema -Schema TestSchema4 + $schema = Get-DbaDatabase -SqlInstance $server1 -Database $newDbName | New-DbaDbSchema -Schema TestSchema4 $schema.Count | Should -Be 1 $schema.Owner | Should -Be dbo $schema.Name | Should -Be TestSchema4 diff --git a/tests/Remove-DbaDbSchema.Tests.ps1 b/tests/Remove-DbaDbSchema.Tests.ps1 index 12dfbae446..f532a3b434 100644 --- a/tests/Remove-DbaDbSchema.Tests.ps1 +++ b/tests/Remove-DbaDbSchema.Tests.ps1 @@ -16,11 +16,11 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { BeforeAll { $random = Get-Random - $instance1 = Connect-DbaInstance -SqlInstance $script:instance1 - $instance2 = Connect-DbaInstance -SqlInstance $script:instance2 - $null = Get-DbaProcess -SqlInstance $instance1, $instance2 | Where-Object Program -match dbatools | Stop-DbaProcess -Confirm:$false + $server1 = Connect-DbaInstance -SqlInstance $script:instance1 + $server2 = Connect-DbaInstance -SqlInstance $script:instance2 + $null = Get-DbaProcess -SqlInstance $server1, $server2 | Where-Object Program -match dbatools | Stop-DbaProcess -Confirm:$false $newDbName = "dbatoolsci_newdb_$random" - $newDbs = New-DbaDatabase -SqlInstance $instance1, $instance2 -Name $newDbName + $newDbs = New-DbaDatabase -SqlInstance $server1, $server2 -Name $newDbName } AfterAll { @@ -30,34 +30,34 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { Context "commands work as expected" { It "drops the schema" { - $schema = New-DbaDbSchema -SqlInstance $instance1 -Database $newDbName -Schema TestSchema1 + $schema = New-DbaDbSchema -SqlInstance $server1 -Database $newDbName -Schema TestSchema1 $schema.Count | Should -Be 1 $schema.Name | Should -Be TestSchema1 $schema.Parent.Name | Should -Be $newDbName - Remove-DbaDbSchema -SqlInstance $instance1 -Database $newDbName -Schema TestSchema1 -Confirm:$false + Remove-DbaDbSchema -SqlInstance $server1 -Database $newDbName -Schema TestSchema1 -Confirm:$false - (Get-DbaDbSchema -SqlInstance $instance1 -Database $newDbName -Schema TestSchema1) | Should -BeNullOrEmpty + (Get-DbaDbSchema -SqlInstance $server1 -Database $newDbName -Schema TestSchema1) | Should -BeNullOrEmpty - $schemas = New-DbaDbSchema -SqlInstance $instance1, $instance2 -Database $newDbName -Schema TestSchema2, TestSchema3 + $schemas = New-DbaDbSchema -SqlInstance $server1, $server2 -Database $newDbName -Schema TestSchema2, TestSchema3 $schemas.Count | Should -Be 4 $schemas.Name | Should -Be TestSchema2, TestSchema3, TestSchema2, TestSchema3 $schemas.Parent.Name | Should -Be $newDbName, $newDbName, $newDbName, $newDbName - Remove-DbaDbSchema -SqlInstance $instance1, $instance2 -Database $newDbName -Schema TestSchema2, TestSchema3 -Confirm:$false + Remove-DbaDbSchema -SqlInstance $server1, $server2 -Database $newDbName -Schema TestSchema2, TestSchema3 -Confirm:$false - (Get-DbaDbSchema -SqlInstance $instance1, $instance2 -Database $newDbName -Schema TestSchema2, TestSchema3) | Should -BeNullOrEmpty + (Get-DbaDbSchema -SqlInstance $server1, $server2 -Database $newDbName -Schema TestSchema2, TestSchema3) | Should -BeNullOrEmpty } It "supports piping databases" { - $schema = New-DbaDbSchema -SqlInstance $instance1 -Database $newDbName -Schema TestSchema1 + $schema = New-DbaDbSchema -SqlInstance $server1 -Database $newDbName -Schema TestSchema1 $schema.Count | Should -Be 1 $schema.Name | Should -Be TestSchema1 $schema.Parent.Name | Should -Be $newDbName - Get-DbaDatabase -SqlInstance $instance1 -Database $newDbName | Remove-DbaDbSchema -Schema TestSchema1 -Confirm:$false + Get-DbaDatabase -SqlInstance $server1 -Database $newDbName | Remove-DbaDbSchema -Schema TestSchema1 -Confirm:$false - (Get-DbaDbSchema -SqlInstance $instance1 -Database $newDbName -Schema TestSchema1) | Should -BeNullOrEmpty + (Get-DbaDbSchema -SqlInstance $server1 -Database $newDbName -Schema TestSchema1) | Should -BeNullOrEmpty } } } \ No newline at end of file diff --git a/tests/Set-DbaAgentJobStep.Tests.ps1 b/tests/Set-DbaAgentJobStep.Tests.ps1 index 58e2e4c002..da4fab7650 100644 --- a/tests/Set-DbaAgentJobStep.Tests.ps1 +++ b/tests/Set-DbaAgentJobStep.Tests.ps1 @@ -21,35 +21,35 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { $agentStep1 = New-DbaAgentJobStep -SqlInstance $script:instance1 -Job $job1Instance1 -StepName "Step 1" -OnFailAction QuitWithFailure -OnSuccessAction QuitWithSuccess $agentStep1 = New-DbaAgentJobStep -SqlInstance $script:instance2 -Job $job1Instance2 -StepName "Step 1" -OnFailAction QuitWithFailure -OnSuccessAction QuitWithSuccess - $instance1 = Connect-DbaInstance -SqlInstance $script:instance1 - $instance2 = Connect-DbaInstance -SqlInstance $script:instance2 + $server1 = Connect-DbaInstance -SqlInstance $script:instance1 + $server2 = Connect-DbaInstance -SqlInstance $script:instance2 $login = "db$random" $plaintext = "BigOlPassword!" $password = ConvertTo-SecureString $plaintext -AsPlainText -Force - $null = Invoke-Command2 -ScriptBlock { net user $login $plaintext /add *>&1 } -ComputerName $instance2.ComputerName + $null = Invoke-Command2 -ScriptBlock { net user $login $plaintext /add *>&1 } -ComputerName $server2.ComputerName - $credential = New-DbaCredential -SqlInstance $script:instance2 -Name "dbatoolsci_$random" -Identity "$($instance2.ComputerName)\$login" -Password $password + $credential = New-DbaCredential -SqlInstance $script:instance2 -Name "dbatoolsci_$random" -Identity "$($server2.ComputerName)\$login" -Password $password - $agentProxyInstance2 = New-DbaAgentProxy -SqlInstance $instance2 -Name "dbatoolsci_proxy_1_$random" -ProxyCredential "dbatoolsci_$random" -Subsystem PowerShell + $agentProxyInstance2 = New-DbaAgentProxy -SqlInstance $server2 -Name "dbatoolsci_proxy_1_$random" -ProxyCredential "dbatoolsci_$random" -Subsystem PowerShell $newDbName = "dbatoolsci_newdb_$random" - $newDb = New-DbaDatabase -SqlInstance $instance2 -Name $newDbName + $newDb = New-DbaDatabase -SqlInstance $server2 -Name $newDbName $userName = "user_$random" $password = 'MyV3ry$ecur3P@ssw0rd' $securePassword = ConvertTo-SecureString $password -AsPlainText -Force - $newDBLogin = New-DbaLogin -SqlInstance $instance2 -Login $userName -Password $securePassword -Force - $null = New-DbaDbUser -SqlInstance $instance2 -Database $newDbName -Login $userName + $newDBLogin = New-DbaLogin -SqlInstance $server2 -Login $userName -Password $securePassword -Force + $null = New-DbaDbUser -SqlInstance $server2 -Database $newDbName -Login $userName } AfterAll { - Remove-DbaDatabase -SqlInstance $instance2 -Database "dbatoolsci_newdb_$random" -Confirm:$false - Remove-DbaLogin -SqlInstance $instance2 -Login "user_$random" -Confirm:$false + Remove-DbaDatabase -SqlInstance $server2 -Database "dbatoolsci_newdb_$random" -Confirm:$false + Remove-DbaLogin -SqlInstance $server2 -Login "user_$random" -Confirm:$false Remove-DbaAgentJob -SqlInstance $script:instance1 -Job "dbatoolsci_job_1_$random" -Confirm:$false Remove-DbaAgentJob -SqlInstance $script:instance2 -Job "dbatoolsci_job_1_$random" -Confirm:$false - $null = Invoke-Command2 -ScriptBlock { net user $args /delete *>&1 } -ArgumentList $login -ComputerName $instance2.ComputerName + $null = Invoke-Command2 -ScriptBlock { net user $args /delete *>&1 } -ArgumentList $login -ComputerName $server2.ComputerName $credential.Drop() $agentProxyInstance2.Drop() } @@ -66,12 +66,12 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { } It "pipeline input of pre-connected servers" { - $jobSteps = $instance1, $instance2 | Set-DbaAgentJobStep -Job "dbatoolsci_job_1_$random" -StepName "Step 1" -NewName "Step 1 updated" + $jobSteps = $server1, $server2 | Set-DbaAgentJobStep -Job "dbatoolsci_job_1_$random" -StepName "Step 1" -NewName "Step 1 updated" - (Get-DbaAgentJob -SqlInstance $instance1 -Job "dbatoolsci_job_1_$random").JobSteps | Where-Object Id -eq 1 | Select-Object -ExpandProperty Name | Should -Be "Step 1 updated" - (Get-DbaAgentJob -SqlInstance $instance2 -Job "dbatoolsci_job_1_$random").JobSteps | Where-Object Id -eq 1 | Select-Object -ExpandProperty Name | Should -Be "Step 1 updated" + (Get-DbaAgentJob -SqlInstance $server1 -Job "dbatoolsci_job_1_$random").JobSteps | Where-Object Id -eq 1 | Select-Object -ExpandProperty Name | Should -Be "Step 1 updated" + (Get-DbaAgentJob -SqlInstance $server2 -Job "dbatoolsci_job_1_$random").JobSteps | Where-Object Id -eq 1 | Select-Object -ExpandProperty Name | Should -Be "Step 1 updated" - $jobSteps = $instance1, $instance2 | Set-DbaAgentJobStep -Job "dbatoolsci_job_1_$random" -StepName "Step 1 updated" -NewName "Step 1" + $jobSteps = $server1, $server2 | Set-DbaAgentJobStep -Job "dbatoolsci_job_1_$random" -StepName "Step 1 updated" -NewName "Step 1" } It "use the -Force to add a new step" { @@ -202,7 +202,7 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { Job = $job1Instance2 StepName = "Step 5" Subsystem = "AnalysisCommand" - SubsystemServer = $instance2.Name + SubsystemServer = $server2.Name Command = "AnalysisCommand" CmdExecSuccessCode = 3 OnSuccessAction = "GoToStep" @@ -224,7 +224,7 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { $newJobStep = $results.JobSteps | Where-Object Id -eq 5 $newJobStep.Name | Should -Be "Step 5" $newJobStep.Subsystem | Should -Be "AnalysisCommand" - $newJobStep.Server | Should -Be $instance2.Name + $newJobStep.Server | Should -Be $server2.Name $newJobStep.Command | Should -Be "AnalysisCommand" $newJobStep.DatabaseName | Should -Be $newDbName $newJobStep.RetryAttempts | Should -Be 4 @@ -244,7 +244,7 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { Job = $job1Instance2 StepName = "Step 6" Subsystem = "AnalysisQuery" - SubsystemServer = $instance2.Name + SubsystemServer = $server2.Name Command = "AnalysisQuery" CmdExecSuccessCode = 4 OnSuccessAction = "GoToStep" @@ -266,7 +266,7 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { $newJobStep = $results.JobSteps | Where-Object Id -eq 6 $newJobStep.Name | Should -Be "Step 6" $newJobStep.Subsystem | Should -Be "AnalysisQuery" - $newJobStep.Server | Should -Be $instance2.Name + $newJobStep.Server | Should -Be $server2.Name $newJobStep.Command | Should -Be "AnalysisQuery" $newJobStep.DatabaseName | Should -Be $newDbName $newJobStep.RetryAttempts | Should -Be 5 @@ -286,7 +286,7 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { Job = $job1Instance2 StepName = "Step 7" Subsystem = "CmdExec" - SubsystemServer = $instance2.Name + SubsystemServer = $server2.Name Command = "CmdExec" CmdExecSuccessCode = 5 OnSuccessAction = "GoToStep" @@ -307,7 +307,7 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { $newJobStep = $results.JobSteps | Where-Object Id -eq 7 $newJobStep.Name | Should -Be "Step 7" $newJobStep.Subsystem | Should -Be "CmdExec" - $newJobStep.Server | Should -Be $instance2.Name + $newJobStep.Server | Should -Be $server2.Name $newJobStep.Command | Should -Be "CmdExec" $newJobStep.RetryAttempts | Should -Be 6 $newJobStep.RetryInterval | Should -Be 9 diff --git a/tests/Set-DbaDbSchema.Tests.ps1 b/tests/Set-DbaDbSchema.Tests.ps1 index 637995e685..12a300cb5a 100644 --- a/tests/Set-DbaDbSchema.Tests.ps1 +++ b/tests/Set-DbaDbSchema.Tests.ps1 @@ -16,20 +16,20 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { BeforeAll { $random = Get-Random - $instance1 = Connect-DbaInstance -SqlInstance $script:instance1 - $instance2 = Connect-DbaInstance -SqlInstance $script:instance2 - $null = Get-DbaProcess -SqlInstance $instance1, $instance2 | Where-Object Program -match dbatools | Stop-DbaProcess -Confirm:$false + $server1 = Connect-DbaInstance -SqlInstance $script:instance1 + $server2 = Connect-DbaInstance -SqlInstance $script:instance2 + $null = Get-DbaProcess -SqlInstance $server1, $server2 | Where-Object Program -match dbatools | Stop-DbaProcess -Confirm:$false $newDbName = "dbatoolsci_newdb_$random" - $newDbs = New-DbaDatabase -SqlInstance $instance1, $instance2 -Name $newDbName + $newDbs = New-DbaDatabase -SqlInstance $server1, $server2 -Name $newDbName $userName = "user_$random" $userName2 = "user2_$random" $password = 'MyV3ry$ecur3P@ssw0rd' $securePassword = ConvertTo-SecureString $password -AsPlainText -Force - $logins = New-DbaLogin -SqlInstance $instance1, $instance2 -Login $userName, $userName2 -Password $securePassword -Force + $logins = New-DbaLogin -SqlInstance $server1, $server2 -Login $userName, $userName2 -Password $securePassword -Force - $null = New-DbaDbUser -SqlInstance $instance1, $instance2 -Database $newDbName -Login $userName - $null = New-DbaDbUser -SqlInstance $instance1, $instance2 -Database $newDbName -Login $userName2 + $null = New-DbaDbUser -SqlInstance $server1, $server2 -Database $newDbName -Login $userName + $null = New-DbaDbUser -SqlInstance $server1, $server2 -Database $newDbName -Login $userName2 } AfterAll { @@ -40,25 +40,25 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { Context "commands work as expected" { It "updates the schema to a different owner" { - $schema = New-DbaDbSchema -SqlInstance $instance1 -Database $newDbName -Schema TestSchema1 -SchemaOwner $userName + $schema = New-DbaDbSchema -SqlInstance $server1 -Database $newDbName -Schema TestSchema1 -SchemaOwner $userName $schema.Count | Should -Be 1 $schema.Owner | Should -Be $userName $schema.Name | Should -Be TestSchema1 $schema.Parent.Name | Should -Be $newDbName - $updatedSchema = Set-DbaDbSchema -SqlInstance $instance1 -Database $newDbName -Schema TestSchema1 -SchemaOwner $userName2 + $updatedSchema = Set-DbaDbSchema -SqlInstance $server1 -Database $newDbName -Schema TestSchema1 -SchemaOwner $userName2 $updatedSchema.Count | Should -Be 1 $updatedSchema.Owner | Should -Be $userName2 $updatedSchema.Name | Should -Be TestSchema1 $updatedSchema.Parent.Name | Should -Be $newDbName - $schemas = New-DbaDbSchema -SqlInstance $instance1, $instance2 -Database $newDbName -Schema TestSchema2, TestSchema3 -SchemaOwner $userName + $schemas = New-DbaDbSchema -SqlInstance $server1, $server2 -Database $newDbName -Schema TestSchema2, TestSchema3 -SchemaOwner $userName $schemas.Count | Should -Be 4 $schemas.Owner | Should -Be $userName, $userName, $userName, $userName $schemas.Name | Should -Be TestSchema2, TestSchema3, TestSchema2, TestSchema3 $schemas.Parent.Name | Should -Be $newDbName, $newDbName, $newDbName, $newDbName - $updatedSchemas = Set-DbaDbSchema -SqlInstance $instance1, $instance2 -Database $newDbName -Schema TestSchema2, TestSchema3 -SchemaOwner $userName2 + $updatedSchemas = Set-DbaDbSchema -SqlInstance $server1, $server2 -Database $newDbName -Schema TestSchema2, TestSchema3 -SchemaOwner $userName2 $updatedSchemas.Count | Should -Be 4 $schemas.Owner | Should -Be $userName2, $userName2, $userName2, $userName2 $schemas.Name | Should -Be TestSchema2, TestSchema3, TestSchema2, TestSchema3 @@ -66,7 +66,7 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { } It "supports piping databases" { - $schema = Get-DbaDatabase -SqlInstance $instance1 -Database $newDbName | Set-DbaDbSchema -Schema TestSchema1 -SchemaOwner $userName + $schema = Get-DbaDatabase -SqlInstance $server1 -Database $newDbName | Set-DbaDbSchema -Schema TestSchema1 -SchemaOwner $userName $schema.Count | Should -Be 1 $schema.Owner | Should -Be $userName $schema.Name | Should -Be TestSchema1 diff --git a/tests/Watch-DbaDbLogin.Tests.ps1 b/tests/Watch-DbaDbLogin.Tests.ps1 index 3e4f5af530..b00f74aa8a 100644 --- a/tests/Watch-DbaDbLogin.Tests.ps1 +++ b/tests/Watch-DbaDbLogin.Tests.ps1 @@ -29,8 +29,8 @@ Describe "$commandname Integration Tests" -Tags "IntegrationTests" { $script:instance1, $script:instance2 | Out-File $testFile - $instance1 = Connect-DbaInstance -SqlInstance $script:instance1 - $instance2 = Connect-DbaInstance -SqlInstance $script:instance2 + $server1 = Connect-DbaInstance -SqlInstance $script:instance1 + $server2 = Connect-DbaInstance -SqlInstance $script:instance2 $regServer1 = Add-DbaRegServer -SqlInstance $script:instance1 -ServerName $script:instance1 -Name "dbatoolsci_instance1_$random" $regServer2 = Add-DbaRegServer -SqlInstance $script:instance1 -ServerName $script:instance2 -Name "dbatoolsci_instance2_$random" @@ -50,7 +50,7 @@ Describe "$commandname Integration Tests" -Tags "IntegrationTests" { } It "Pipeline of instances" { - $instance1, $instance2 | Watch-DbaDbLogin -SqlInstance $script:instance1 -Database $databaseName -Table $tableName2 -EnableException + $server1, $server2 | Watch-DbaDbLogin -SqlInstance $script:instance1 -Database $databaseName -Table $tableName2 -EnableException $result = Get-DbaDbTable -SqlInstance $script:instance1 -Database $databaseName -Table $tableName2 -IncludeSystemDBs $result.Name | Should Be $tableName2 $result.Count | Should BeGreaterThan 0 From 130d02908a15c2be4238303823d92be971d2d0f7 Mon Sep 17 00:00:00 2001 From: andreasjordan Date: Fri, 11 Oct 2024 12:34:35 +0200 Subject: [PATCH 2/2] exclude Set-DbaAgentJobStep for now --- tests/Set-DbaAgentJobStep.Tests.ps1 | 42 ++++++++++++++--------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/tests/Set-DbaAgentJobStep.Tests.ps1 b/tests/Set-DbaAgentJobStep.Tests.ps1 index da4fab7650..58e2e4c002 100644 --- a/tests/Set-DbaAgentJobStep.Tests.ps1 +++ b/tests/Set-DbaAgentJobStep.Tests.ps1 @@ -21,35 +21,35 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { $agentStep1 = New-DbaAgentJobStep -SqlInstance $script:instance1 -Job $job1Instance1 -StepName "Step 1" -OnFailAction QuitWithFailure -OnSuccessAction QuitWithSuccess $agentStep1 = New-DbaAgentJobStep -SqlInstance $script:instance2 -Job $job1Instance2 -StepName "Step 1" -OnFailAction QuitWithFailure -OnSuccessAction QuitWithSuccess - $server1 = Connect-DbaInstance -SqlInstance $script:instance1 - $server2 = Connect-DbaInstance -SqlInstance $script:instance2 + $instance1 = Connect-DbaInstance -SqlInstance $script:instance1 + $instance2 = Connect-DbaInstance -SqlInstance $script:instance2 $login = "db$random" $plaintext = "BigOlPassword!" $password = ConvertTo-SecureString $plaintext -AsPlainText -Force - $null = Invoke-Command2 -ScriptBlock { net user $login $plaintext /add *>&1 } -ComputerName $server2.ComputerName + $null = Invoke-Command2 -ScriptBlock { net user $login $plaintext /add *>&1 } -ComputerName $instance2.ComputerName - $credential = New-DbaCredential -SqlInstance $script:instance2 -Name "dbatoolsci_$random" -Identity "$($server2.ComputerName)\$login" -Password $password + $credential = New-DbaCredential -SqlInstance $script:instance2 -Name "dbatoolsci_$random" -Identity "$($instance2.ComputerName)\$login" -Password $password - $agentProxyInstance2 = New-DbaAgentProxy -SqlInstance $server2 -Name "dbatoolsci_proxy_1_$random" -ProxyCredential "dbatoolsci_$random" -Subsystem PowerShell + $agentProxyInstance2 = New-DbaAgentProxy -SqlInstance $instance2 -Name "dbatoolsci_proxy_1_$random" -ProxyCredential "dbatoolsci_$random" -Subsystem PowerShell $newDbName = "dbatoolsci_newdb_$random" - $newDb = New-DbaDatabase -SqlInstance $server2 -Name $newDbName + $newDb = New-DbaDatabase -SqlInstance $instance2 -Name $newDbName $userName = "user_$random" $password = 'MyV3ry$ecur3P@ssw0rd' $securePassword = ConvertTo-SecureString $password -AsPlainText -Force - $newDBLogin = New-DbaLogin -SqlInstance $server2 -Login $userName -Password $securePassword -Force - $null = New-DbaDbUser -SqlInstance $server2 -Database $newDbName -Login $userName + $newDBLogin = New-DbaLogin -SqlInstance $instance2 -Login $userName -Password $securePassword -Force + $null = New-DbaDbUser -SqlInstance $instance2 -Database $newDbName -Login $userName } AfterAll { - Remove-DbaDatabase -SqlInstance $server2 -Database "dbatoolsci_newdb_$random" -Confirm:$false - Remove-DbaLogin -SqlInstance $server2 -Login "user_$random" -Confirm:$false + Remove-DbaDatabase -SqlInstance $instance2 -Database "dbatoolsci_newdb_$random" -Confirm:$false + Remove-DbaLogin -SqlInstance $instance2 -Login "user_$random" -Confirm:$false Remove-DbaAgentJob -SqlInstance $script:instance1 -Job "dbatoolsci_job_1_$random" -Confirm:$false Remove-DbaAgentJob -SqlInstance $script:instance2 -Job "dbatoolsci_job_1_$random" -Confirm:$false - $null = Invoke-Command2 -ScriptBlock { net user $args /delete *>&1 } -ArgumentList $login -ComputerName $server2.ComputerName + $null = Invoke-Command2 -ScriptBlock { net user $args /delete *>&1 } -ArgumentList $login -ComputerName $instance2.ComputerName $credential.Drop() $agentProxyInstance2.Drop() } @@ -66,12 +66,12 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { } It "pipeline input of pre-connected servers" { - $jobSteps = $server1, $server2 | Set-DbaAgentJobStep -Job "dbatoolsci_job_1_$random" -StepName "Step 1" -NewName "Step 1 updated" + $jobSteps = $instance1, $instance2 | Set-DbaAgentJobStep -Job "dbatoolsci_job_1_$random" -StepName "Step 1" -NewName "Step 1 updated" - (Get-DbaAgentJob -SqlInstance $server1 -Job "dbatoolsci_job_1_$random").JobSteps | Where-Object Id -eq 1 | Select-Object -ExpandProperty Name | Should -Be "Step 1 updated" - (Get-DbaAgentJob -SqlInstance $server2 -Job "dbatoolsci_job_1_$random").JobSteps | Where-Object Id -eq 1 | Select-Object -ExpandProperty Name | Should -Be "Step 1 updated" + (Get-DbaAgentJob -SqlInstance $instance1 -Job "dbatoolsci_job_1_$random").JobSteps | Where-Object Id -eq 1 | Select-Object -ExpandProperty Name | Should -Be "Step 1 updated" + (Get-DbaAgentJob -SqlInstance $instance2 -Job "dbatoolsci_job_1_$random").JobSteps | Where-Object Id -eq 1 | Select-Object -ExpandProperty Name | Should -Be "Step 1 updated" - $jobSteps = $server1, $server2 | Set-DbaAgentJobStep -Job "dbatoolsci_job_1_$random" -StepName "Step 1 updated" -NewName "Step 1" + $jobSteps = $instance1, $instance2 | Set-DbaAgentJobStep -Job "dbatoolsci_job_1_$random" -StepName "Step 1 updated" -NewName "Step 1" } It "use the -Force to add a new step" { @@ -202,7 +202,7 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { Job = $job1Instance2 StepName = "Step 5" Subsystem = "AnalysisCommand" - SubsystemServer = $server2.Name + SubsystemServer = $instance2.Name Command = "AnalysisCommand" CmdExecSuccessCode = 3 OnSuccessAction = "GoToStep" @@ -224,7 +224,7 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { $newJobStep = $results.JobSteps | Where-Object Id -eq 5 $newJobStep.Name | Should -Be "Step 5" $newJobStep.Subsystem | Should -Be "AnalysisCommand" - $newJobStep.Server | Should -Be $server2.Name + $newJobStep.Server | Should -Be $instance2.Name $newJobStep.Command | Should -Be "AnalysisCommand" $newJobStep.DatabaseName | Should -Be $newDbName $newJobStep.RetryAttempts | Should -Be 4 @@ -244,7 +244,7 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { Job = $job1Instance2 StepName = "Step 6" Subsystem = "AnalysisQuery" - SubsystemServer = $server2.Name + SubsystemServer = $instance2.Name Command = "AnalysisQuery" CmdExecSuccessCode = 4 OnSuccessAction = "GoToStep" @@ -266,7 +266,7 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { $newJobStep = $results.JobSteps | Where-Object Id -eq 6 $newJobStep.Name | Should -Be "Step 6" $newJobStep.Subsystem | Should -Be "AnalysisQuery" - $newJobStep.Server | Should -Be $server2.Name + $newJobStep.Server | Should -Be $instance2.Name $newJobStep.Command | Should -Be "AnalysisQuery" $newJobStep.DatabaseName | Should -Be $newDbName $newJobStep.RetryAttempts | Should -Be 5 @@ -286,7 +286,7 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { Job = $job1Instance2 StepName = "Step 7" Subsystem = "CmdExec" - SubsystemServer = $server2.Name + SubsystemServer = $instance2.Name Command = "CmdExec" CmdExecSuccessCode = 5 OnSuccessAction = "GoToStep" @@ -307,7 +307,7 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { $newJobStep = $results.JobSteps | Where-Object Id -eq 7 $newJobStep.Name | Should -Be "Step 7" $newJobStep.Subsystem | Should -Be "CmdExec" - $newJobStep.Server | Should -Be $server2.Name + $newJobStep.Server | Should -Be $instance2.Name $newJobStep.Command | Should -Be "CmdExec" $newJobStep.RetryAttempts | Should -Be 6 $newJobStep.RetryInterval | Should -Be 9