Skip to content
Permalink
Browse files

initial commit (#5528)

  • Loading branch information...
potatoqualitee committed May 15, 2019
1 parent d7e2643 commit 9882af6df1434e31fb91d755db948aab5ca45676
Showing with 79 additions and 0 deletions.
  1. +60 −0 functions/Get-DbatoolsChangeLog.ps1
  2. +19 −0 tests/Get-DbatoolsChangeLog.Tests.ps1
@@ -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
}
}
@@ -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.
You can’t perform that action at this time.