Skip to content

Commit 6ff3958

Browse files
committed
Merge branch 'development' of https://github.com/LowlyDBA/dba-multitool into development
2 parents a8df4a2 + 1040ab0 commit 6ff3958

File tree

11 files changed

+274
-8774
lines changed

11 files changed

+274
-8774
lines changed

appveyor/appveyor.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ for:
9090
# Setup codecov, SQL Cover
9191
before_test:
9292
- ps: .\appveyor\install_dependencies.ps1 -CodeCoverage
93-
- ps: choco install codecov --no-progress --limit-output | Out-Null
9493

9594
# Run tests with SQL Cover analysis
9695
test_script:

appveyor/install_dependencies.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ If ($CodeCoverage.IsPresent) {
3535
If (!(Get-Package -Name GOEddie.SQLCover -ErrorAction SilentlyContinue)) {
3636
Install-Package GOEddie.SQLCover -Force | Out-Null
3737
}
38+
39+
# Install codecov tracker
40+
choco install codecov --no-progress --limit-output | Out-Null
3841
}
3942

4043
# Wait for Jobs before proceeding

appveyor/install_tsqlt.ps1

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,67 @@
1-
param(
2-
[Parameter()]
1+
param(
2+
[Parameter()]
33
[String]$SqlInstance = $env:DB_INSTANCE,
44
[String]$Database = $env:TARGET_DB,
5-
[String]$CLRScript = "tests\tSQLt\SetClrEnabled.sql",
6-
[String]$CreateDBScript = "tests\tSQLt\CreateDatabase.sql",
7-
[String]$tSQLtInstallScript = "tests\tSQLt\tSQLt.class.sql",
85
[String]$Color = "Green",
9-
[String]$Master = "master",
106
[string]$User = $env:AZURE_SQL_USER,
117
[string]$Pass = $env:AZURE_SQL_PASS,
128
[bool]$IsAzureSQL = [System.Convert]::ToBoolean($env:AzureSQL)
139
)
1410

15-
Write-Host "Installing tSQLt..." -ForegroundColor $Color
11+
Write-Host "Downloading and installing tSQLt..." -ForegroundColor $Color
12+
13+
# BaseUrl gets the latest version by default - blocked by https://github.com/LowlyDBA/dba-multitool/issues/165
14+
$Version = "1-0-5873-27393"
15+
$DownloadUrl = "http://tsqlt.org/download/tsqlt/?version=" + $Version
16+
$TempPath = [System.IO.Path]::GetTempPath()
17+
$ZipFile = Join-Path $TempPath "tSQLt.zip"
18+
$ZipFolder = Join-Path $TempPath "tSQLt"
19+
#$SetupFile = Join-Path $ZipFolder "PrepareServer.sql" # Used in latest version after 1.0.5873.27393
20+
$SetupFile = Join-Path $ZipFolder "SetClrEnabled.sql"
21+
$InstallFile = Join-Path $ZipFolder "tSQLt.class.sql"
22+
$CreateDbQuery = "CREATE DATABASE [tSQLt];"
23+
$CLRSecurityQuery = "
24+
/* Turn off CLR Strict for 2017+ fix */
25+
IF EXISTS (SELECT 1 FROM sys.configurations WHERE name = 'clr strict security')
26+
BEGIN
27+
EXEC sp_configure 'show advanced options', 1;
28+
RECONFIGURE;
29+
30+
EXEC sp_configure 'clr strict security', 0;
31+
RECONFIGURE;
32+
END
33+
GO"
34+
35+
36+
# Download
37+
Try {
38+
Invoke-WebRequest -Uri $DownloadUrl -OutFile $ZipFile -ErrorAction Stop -UseBasicParsing
39+
Expand-Archive -Path $ZipFile -DestinationPath $ZipFolder -Force
40+
}
41+
42+
Catch {
43+
Write-Error -Message "Error downloading tSQLt - try manually fetching from $DownloadUrl"
44+
}
1645

1746
$Hash = @{
1847
SqlInstance = $SqlInstance
19-
Database = $Database
48+
Database = $Database
2049
EnableException = $true
2150
}
2251

52+
# Setup
2353
If ($IsAzureSQL) {
2454
$SecPass = ConvertTo-SecureString -String $Pass -AsPlainText -Force
2555
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $SecPass
2656
$Hash.add("SqlCredential", $Credential)
27-
28-
Invoke-DbaQuery @hash -File $tSQLtInstallScript
2957
}
3058

3159
Else {
32-
Invoke-DbaQuery -SqlInstance $SqlInstance -Database $Master -File $clrscript | Out-Null
33-
Invoke-DbaQuery -SqlInstance $SqlInstance -Database $Master -File $CreateDBScript | Out-Null
34-
Invoke-DbaQuery @Hash -File $tSQLtInstallScript -MessagesToOutput
60+
Invoke-DbaQuery -SqlInstance $SqlInstance -Database "master" -Query $CreateDbQuery
61+
# DbaQuery doesn't play nice with the setup script GOs - default back to sqlcmd
62+
Invoke-Command -ScriptBlock { sqlcmd -S $SqlInstance -d $Database -i $SetupFile } | Out-Null
63+
Invoke-DbaQuery @Hash -Query $CLRSecurityQuery
3564
}
65+
66+
# Install
67+
Invoke-DbaQuery @Hash -File $InstallFile

appveyor/sqlcover/Coverage.opencoverxml

Lines changed: 225 additions & 225 deletions
Large diffs are not rendered by default.

tests/sp_sizeoptimiser.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ BeforeAll {
88
Describe "sp_sizeoptimiser" {
99
Context "tSQLt Tests" {
1010
BeforeAll {
11-
$StoredProc = $StoredProc
11+
$StoredProc = "sp_sizeoptimiser"
1212
$TestPath = "tests\"
1313
$RunTestQuery = "EXEC tSQLt.Run '$StoredProc'"
1414

tests/tSQLt/CreateDatabase.sql

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)