Skip to content

Commit

Permalink
Merge branch 'release/1.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Steffen committed Sep 30, 2022
2 parents e362621 + 5128c4a commit 1f6be67
Show file tree
Hide file tree
Showing 28 changed files with 250 additions and 201 deletions.
16 changes: 8 additions & 8 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@
"label": "Test",
"group": "test",
"type": "shell",
"command": "Invoke-Pester -Output Detailed",
"command": "Invoke-Pester",
"options": {
"cwd": "test"
"cwd": "${workspaceFolder}/test"
},
"problemMatcher": "$msCompile",
"presentation": {
Expand All @@ -76,9 +76,9 @@
"label": "Test SqlLocalDB",
"group": "test",
"type": "shell",
"command": "Invoke-Pester -Configuration @{ Filter = @{ Tag = 'SqlLocalDB' }; Output = 'Detailed' }",
"command": "Invoke-Pester -Configuration @{ Filter = @{ Tag = 'SqlLocalDB' } }",
"options": {
"cwd": "test"
"cwd": "${workspaceFolder}/test"
},
"problemMatcher": "$msCompile",
"presentation": {
Expand All @@ -91,9 +91,9 @@
"label": "Test Docker",
"group": "test",
"type": "shell",
"command": "Invoke-Pester -Configuration @{ Filter = @{ Tag = 'Docker' }; Output = 'Detailed' }",
"command": "Invoke-Pester -Configuration @{ Filter = @{ Tag = 'Docker' } }",
"options": {
"cwd": "test"
"cwd": "${workspaceFolder}/test"
},
"problemMatcher": "$msCompile",
"presentation": {
Expand All @@ -106,9 +106,9 @@
"label": "Test Azure",
"group": "test",
"type": "shell",
"command": "Invoke-Pester -Configuration @{ Filter = @{ Tag = 'Azure' }; Output = 'Detailed' }",
"command": "Invoke-Pester -Configuration @{ Filter = @{ Tag = 'Azure' } }",
"options": {
"cwd": "test"
"cwd": "${workspaceFolder}/test"
},
"problemMatcher": "$msCompile",
"presentation": {
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.5.0] - 2022-09-30

### Added

- Parameter to specify sql server version in `New-LocalInstance`.

## [1.4.0] - 2022-09-27

## Added

- Added `Clear-LocalInstance` command.
- Added DatabaseCredential property to `New-DockerInstance`.

## [1.3.0] - 2022-08-07
Expand Down
19 changes: 17 additions & 2 deletions docs/New-SqlTestLocalInstance.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Returns connection parameters to new localDb.
## SYNTAX

```
New-SqlTestLocalInstance [[-Name] <String>] [<CommonParameters>]
New-SqlTestLocalInstance [[-Name] <String>] [[-Version] <Version>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -46,7 +46,22 @@ Aliases:

Required: False
Position: 1
Default value: "test-$( New-DatabaseName )"
Default value: ( New-DatabaseName )
Accept pipeline input: False
Accept wildcard characters: False
```
### -Version
Specifies the version of the sql server.
```yaml
Type: Version
Parameter Sets: (All)
Aliases:

Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
Expand Down
2 changes: 1 addition & 1 deletion src/PsSqlTestServer.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'PsSqlTestServer.psm1'

# Version number of this module.
ModuleVersion = '1.4.0'
ModuleVersion = '1.5.0'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
2 changes: 1 addition & 1 deletion src/Public/Clear-LocalInstance.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function Clear-LocalInstance {
[switch] $WhatIf
)

Import-Module PsSqlLocalDb -ErrorAction Stop
Import-Module PsSqlLocalDb -MinimumVersion 0.3 -ErrorAction Stop

Get-LocalInstance -First $null | Where-Object Name -Like test-* | Remove-LocalInstance -WhatIf:$WhatIf
}
2 changes: 1 addition & 1 deletion src/Public/Get-LocalInstance.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function Get-LocalInstance {
[int] $First = 1
)

Import-Module PsSqlLocalDb -ErrorAction Stop
Import-Module PsSqlLocalDb -MinimumVersion 0.3 -ErrorAction Stop

$selectParam = @{}
if ( $First ) {
Expand Down
14 changes: 11 additions & 3 deletions src/Public/New-LocalInstance.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,21 @@ function New-LocalInstance {
# Specifies the name of the instance to create.
[Parameter()]
[ValidateNotNullOrEmpty()]
[string] $Name = "test-$( New-DatabaseName )"
[string] $Name = ( New-DatabaseName ),

# Specifies the version of the sql server.
[Parameter()]
[System.Version] $Version
)

Import-Module PsSqlLocalDb -ErrorAction Stop
Import-Module PsSqlLocalDb -MinimumVersion 0.3 -ErrorAction Stop

# create instance
$instance = New-LocalDbInstance -Name $Name
if ( $Version ) {
$instance = New-LocalDbInstance -Name $Name -Version $Version
} else {
$instance = New-LocalDbInstance -Name $Name
}

# add metadata
$instance | Add-Member 'DataSource' "(LocalDb)\$( $instance.Name )"
Expand Down
2 changes: 1 addition & 1 deletion src/Public/Remove-LocalInstance.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function Remove-LocalInstance {
)

begin {
Import-Module PsSqlLocalDb -ErrorAction Stop
Import-Module PsSqlLocalDb -MinimumVersion 0.3 -ErrorAction Stop
}

process {
Expand Down
4 changes: 2 additions & 2 deletions src/Public/Test-LocalDb.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ function Test-LocalDb {
[CmdletBinding()]
param ()

if ( -Not ( Import-Module PsSqlLocalDb -PassThru -ErrorAction SilentlyContinue )) {
Write-Warning 'PsSqlLocalDb is not installed.'
if ( -Not ( Import-Module PsSqlLocalDb -MinimumVersion 0.3 -PassThru -ErrorAction SilentlyContinue )) {
Write-Warning 'PsSqlLocalDb is not installed in required version.'
return $false
}

Expand Down
12 changes: 6 additions & 6 deletions tasks/Build.Tasks.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
requires ModuleName

[System.IO.DirectoryInfo] $SourceDirectory = "$PsScriptRoot\..\src"
[System.IO.DirectoryInfo] $SourceManifest = "$SourceDirectory\$ModuleName.psd1"
[System.IO.DirectoryInfo] $PublishDirectory = "$PsScriptRoot\..\publish"
[System.IO.DirectoryInfo] $DocumentationDirectory = "$PsScriptRoot\..\docs"
[System.IO.DirectoryInfo] $ModulePublishDirectory = "$PublishDirectory\$ModuleName"
[System.IO.DirectoryInfo] $SourceDirectory = "$PsScriptRoot/../src"
[System.IO.DirectoryInfo] $SourceManifest = "$SourceDirectory/$ModuleName.psd1"
[System.IO.DirectoryInfo] $PublishDirectory = "$PsScriptRoot/../publish"
[System.IO.DirectoryInfo] $DocumentationDirectory = "$PsScriptRoot/../docs"
[System.IO.DirectoryInfo] $ModulePublishDirectory = "$PublishDirectory/$ModuleName"

# Synopsis: Remove all temporary files.
task Clean -Jobs {
Expand Down Expand Up @@ -50,7 +50,7 @@ task SetPrerelease -If $BuildNumber {
# Synopsis: Build the module.
task Build -Jobs Clean, Doc.Update, PreparePublishDirectory, {
Copy-Item -Path $SourceDirectory -Destination $ModulePublishDirectory -Recurse
[System.IO.FileInfo] $Global:Manifest = "$ModulePublishDirectory\$ModuleName.psd1"
[System.IO.FileInfo] $Global:Manifest = "$ModulePublishDirectory/$ModuleName.psd1"
}, SetPrerelease

# Synopsis: Install the module.
Expand Down
2 changes: 1 addition & 1 deletion tasks/Dependencies.Tasks.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ task InstallBuildDependencies -Jobs {

task InstallTestDependencies -Jobs {
Install-Module psdocker -Scope CurrentUser -ErrorAction Stop -Verbose -AllowPrerelease
Install-Module PsSqlLocalDb -Scope CurrentUser -ErrorAction Stop -Verbose -AllowPrerelease
Install-Module PsSqlLocalDb -Scope CurrentUser -MinimumVersion 0.3 -ErrorAction Stop -Verbose -AllowPrerelease
Install-Module PsSqlClient -Scope CurrentUser -ErrorAction Stop -Verbose -AllowPrerelease -AllowClobber
}

Expand Down
2 changes: 1 addition & 1 deletion test/Clear-LocalInstance.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Describe Clear-LocalInstance {
BeforeEach {
$Instance = @((New-SqlTestLocalInstance), (New-SqlTestLocalInstance))

Import-Module PsSqlLocalDb -ErrorAction Stop
Import-Module PsSqlLocalDb -MinimumVersion 0.3 -ErrorAction Stop
}

It Works-with-WhatIf {
Expand Down
10 changes: 5 additions & 5 deletions test/Get-Instance.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#Requires -Modules @{ ModuleName='Pester'; ModuleVersion='5.0.0' }

Describe 'Get-Instance' {
Describe Get-Instance {

BeforeAll {
Import-Module $PSScriptRoot\..\src\PsSqlTestServer.psd1 -Force -ErrorAction Stop
}

It 'Provides a SQL server' {
$Script:Instance = Get-SqlTestInstance
$Instance = Get-SqlTestInstance

$Script:Instance | Should -Not -BeNullOrEmpty
$Script:Instance.ConnectionString | Should -Not -BeNullOrEmpty
$Script:Instance.DataSource | Should -Not -BeNullOrEmpty
$Instance | Should -Not -BeNullOrEmpty
$Instance.ConnectionString | Should -Not -BeNullOrEmpty
$Instance.DataSource | Should -Not -BeNullOrEmpty
}
}
20 changes: 10 additions & 10 deletions test/Get-LocalInstance.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#Requires -Modules @{ ModuleName='Pester'; ModuleVersion='5.0.0' }

Describe 'Get-LocalInstance' -Tag SqlLocalDB {
Describe Get-LocalInstance -Tag SqlLocalDB {

BeforeDiscovery {
Import-Module $PSScriptRoot\..\src\PsSqlTestServer.psd1 -Force -ErrorAction Stop
}

Context 'LocalDb' -Skip:( -Not ( Test-SqlTestLocalDb )) {
Context LocalDb -Skip:( -Not ( Test-SqlTestLocalDb )) {

It 'Returns values' {
$result = Get-SqlTestLocalInstance
Expand All @@ -18,30 +18,30 @@ Describe 'Get-LocalInstance' -Tag SqlLocalDB {
}

BeforeDiscovery {
$Script:PsSqlClient = Import-Module PsSqlClient -PassThru -ErrorAction SilentlyContinue
$PsSqlClient = Import-Module PsSqlClient -PassThru -ErrorAction SilentlyContinue
}

Context 'PsSqlClient' -Skip:( -Not $Script:PsSqlClient ) {
Context PsSqlClient -Skip:( -Not $PsSqlClient ) {

BeforeAll {
$Script:LocalDb = Get-SqlTestLocalInstance
$LocalDb = Get-SqlTestLocalInstance
}

It 'Connects by Pipeline' {
$Script:SqlConnection = $Script:LocalDb | Connect-TSqlInstance
$SqlConnection = $LocalDb | Connect-TSqlInstance
}

It 'Connects by DataSource' {
$Script:SqlConnection = Connect-TSqlInstance -DataSource $Script:LocalDb.DataSource -ConnectTimeout $Script:LocalDb.ConnectTimeout
$SqlConnection = Connect-TSqlInstance -DataSource $LocalDb.DataSource -ConnectTimeout $LocalDb.ConnectTimeout
}

It 'Connects by ConnectionString' {
$Script:SqlConnection = Connect-TSqlInstance -ConnectionString $Script:LocalDb.ConnectionString
$SqlConnection = Connect-TSqlInstance -ConnectionString $LocalDb.ConnectionString
}

AfterEach {
if ( $Script:SqlConnection ) {
Disconnect-TSqlInstance -Connection $Script:SqlConnection
if ( $SqlConnection ) {
Disconnect-TSqlInstance -Connection $SqlConnection
}
}
}
Expand Down
48 changes: 24 additions & 24 deletions test/New-AzureDatabase.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
#Requires -Modules @{ ModuleName='Pester'; ModuleVersion='5.0.0' }

Describe 'New-AzureDatabase' -Tag Azure {
Describe New-AzureDatabase -Tag Azure {

BeforeDiscovery {
Import-Module $PSScriptRoot\..\src\PsSqlTestServer.psd1 -Force -ErrorAction Stop
}

BeforeAll {
$Script:Subscription = 'Visual Studio Enterprise – MPN'
$Subscription = 'Visual Studio Enterprise – MPN'
}

Context 'Azure' -Skip:( -Not ( Test-SqlTestAzure )) {
Context Azure -Skip:( -Not ( Test-SqlTestAzure )) {

Context 'Instance' {
Context Instance {
BeforeAll {
$Script:Instance = New-SqlTestAzureInstance -Subscription $Script:Subscription
$Instance = New-SqlTestAzureInstance -Subscription $Subscription
}

AfterAll {
$Script:Instance | Remove-SqlTestAzureInstance
$Instance | Remove-SqlTestAzureInstance
}

Context 'Database' {
Context Database {

BeforeAll {
$Script:Database = New-SqlTestAzureDatabase -Instance $Script:Instance
$Database = New-SqlTestAzureDatabase -Instance $Instance
}

AfterAll {
$Script:Database | Remove-SqlTestAzureDatabase
$Database | Remove-SqlTestAzureDatabase
}

It 'Returns values' {
$Script:Database | Should -Not -BeNullOrEmpty
$Script:Database.DataSource | Should -Not -BeNullOrEmpty
$Script:Database.InitialCatalog | Should -Not -BeNullOrEmpty
$Script:Database.ConnectTimeout | Should -Not -BeNullOrEmpty
$Script:Database.ConnectionString | Should -Not -BeNullOrEmpty
$Database | Should -Not -BeNullOrEmpty
$Database.DataSource | Should -Not -BeNullOrEmpty
$Database.InitialCatalog | Should -Not -BeNullOrEmpty
$Database.ConnectTimeout | Should -Not -BeNullOrEmpty
$Database.ConnectionString | Should -Not -BeNullOrEmpty
}

BeforeDiscovery {
$Script:PsSqlClient = Import-Module PsSqlClient -PassThru -ErrorAction SilentlyContinue
$PsSqlClient = Import-Module PsSqlClient -PassThru -ErrorAction SilentlyContinue
}

Context 'PsSqlClient' -Skip:( -Not $Script:PsSqlClient ) {
Context PsSqlClient -Skip:( -Not $PsSqlClient ) {

It 'Connects by pipeline' {
$Script:SqlConnection = $Script:Database | Connect-TSqlInstance
$SqlConnection = $Database | Connect-TSqlInstance
}

It 'Connects by DataSource' {
$Script:SqlConnection = Connect-TSqlInstance `
-DataSource $Script:Database.DataSource `
-InitialCatalog $Script:Database.InitialCatalog `
-ConnectTimeout $Script:Database.ConnectTimeout
$SqlConnection = Connect-TSqlInstance `
-DataSource $Database.DataSource `
-InitialCatalog $Database.InitialCatalog `
-ConnectTimeout $Database.ConnectTimeout
}

It 'Connects by ConnectionString' {
$Script:SqlConnection = Connect-TSqlInstance -ConnectionString $Script:Database.ConnectionString
$SqlConnection = Connect-TSqlInstance -ConnectionString $Database.ConnectionString
}

AfterEach {
if ( $Script:SqlConnection ) {
Disconnect-TSqlInstance -Connection $Script:SqlConnection
if ( $SqlConnection ) {
Disconnect-TSqlInstance -Connection $SqlConnection
}
}
}
Expand Down
Loading

0 comments on commit 1f6be67

Please sign in to comment.