-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
201 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
external help file: PsSqlTestServer-help.xml | ||
Module Name: PsSqlTestServer | ||
online version: | ||
schema: 2.0.0 | ||
--- | ||
|
||
# Clear-SqlTestLocalInstance | ||
|
||
## SYNOPSIS | ||
Remove all localdb test instances | ||
|
||
## SYNTAX | ||
|
||
``` | ||
Clear-SqlTestLocalInstance [-WhatIf] [<CommonParameters>] | ||
``` | ||
|
||
## DESCRIPTION | ||
Remove all instances created by New-LocalInstance. | ||
These are identified using the 'test-' prefix. | ||
|
||
## EXAMPLES | ||
|
||
### EXAMPLE 1 | ||
``` | ||
Clear-SqlTestLocalInstance | ||
``` | ||
|
||
## PARAMETERS | ||
|
||
### -WhatIf | ||
Shows what would happen if the cmdlet runs. | ||
The cmdlet is not run. | ||
|
||
```yaml | ||
Type: SwitchParameter | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: False | ||
Position: Named | ||
Default value: False | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### CommonParameters | ||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). | ||
## INPUTS | ||
## OUTPUTS | ||
## NOTES | ||
## RELATED LINKS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
theme: jekyll-theme-minimal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
function Clear-LocalInstance { | ||
|
||
<# | ||
.SYNOPSIS | ||
Remove all localdb test instances | ||
.DESCRIPTION | ||
Remove all instances created by New-LocalInstance. These are identified using the 'test-' prefix. | ||
.EXAMPLE | ||
PS> Clear-SqlTestLocalInstance | ||
#> | ||
|
||
[CmdletBinding()] | ||
param ( | ||
[Parameter()] | ||
[switch] $WhatIf | ||
) | ||
|
||
Import-Module PsSqlLocalDb -ErrorAction Stop | ||
|
||
Get-LocalInstance -First $null | Where-Object Name -Like test-* | Remove-LocalInstance -WhatIf:$WhatIf | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#Requires -Modules @{ ModuleName='Pester'; ModuleVersion='5.0.0' } | ||
|
||
Describe Clear-LocalInstance { | ||
|
||
BeforeAll { | ||
Import-Module $PSScriptRoot\..\src\PsSqlTestServer.psd1 -Force -ErrorAction Stop | ||
} | ||
|
||
Context LocalInstance { | ||
BeforeEach { | ||
$Instance = @((New-SqlTestLocalInstance), (New-SqlTestLocalInstance)) | ||
|
||
Import-Module PsSqlLocalDb -ErrorAction Stop | ||
} | ||
|
||
It Works-with-WhatIf { | ||
Clear-SqlTestLocalInstance -ErrorAction Stop -WhatIf | ||
|
||
( | ||
Get-LocalDbInstance | | ||
Where-Object Name -in ( $Instance | Select-Object -ExpandProperty Name ) | ||
).Count | Should -Be $Instance.Count | ||
} | ||
|
||
It Works { | ||
Clear-SqlTestLocalInstance -ErrorAction Stop | ||
|
||
Get-LocalDbInstance | | ||
Where-Object Name -in ( $Instance | Select-Object -ExpandProperty Name ) | | ||
Should -BeNullOrEmpty | ||
} | ||
} | ||
} |