Skip to content

Commit

Permalink
initial commit (#5528)
Browse files Browse the repository at this point in the history
  • Loading branch information
potatoqualitee authored May 15, 2019
1 parent d7e2643 commit 9882af6
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
60 changes: 60 additions & 0 deletions functions/Get-DbatoolsChangeLog.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
function Get-DbatoolsChangeLog {
<#
.SYNOPSIS
Opens the link to our online change log
.DESCRIPTION
Opens the link to our online change log. To see the local changelog instead, use the Local parameter.
.PARAMETER Local
Return the local change log to the console
.PARAMETER EnableException
By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.
.NOTES
Tags: changelog
Author: Chrissy LeMaire (@cl), netnerds.net
Website: https://dbatools.io
Copyright: (c) 2018 by dbatools, licensed under MIT
License: MIT https://opensource.org/licenses/MIT
.LINK
https://dbatools.io/Get-DbatoolsChangeLog
.EXAMPLE
Get-DbatoolsChangeLog
Opens a browser to our online changelog
.EXAMPLE
Get-DbatoolsChangeLog -Local
Returns the content from changelog.md
#>
[CmdletBinding()]
param (
[switch]$Local,
[switch]$EnableException
)

try {
if (-not $Local) {
Start-Process "https://github.com/sqlcollaborative/dbatools/blob/development/changelog.md"
} else {
$releasenotes = Get-Content $script:PSModuleRoot\changelog.md -Raw

if ($Local) {
($releasenotes -Split "##Local")[0]
} else {
$releasenotes
}
}
} catch {
Stop-Function -Message "Failure" -ErrorRecord $_
return
}
}
19 changes: 19 additions & 0 deletions tests/Get-DbatoolsChangeLog.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
$CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "")
Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan
. "$PSScriptRoot\constants.ps1"

Describe "$CommandName Unit Tests" -Tag 'UnitTests' {
Context "Validate parameters" {
[object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')}
[object[]]$knownParameters = 'Local', 'EnableException'
$knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters
It "Should only contain our specific parameters" {
(@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0
}
}
}
<#
Integration test should appear below and are custom to the command you are writing.
Read https://github.com/sqlcollaborative/dbatools/blob/development/contributing.md#tests
for more guidence.
#>

0 comments on commit 9882af6

Please sign in to comment.