Skip to content
Chrissy LeMaire edited this page Dec 22, 2017 · 19 revisions

This wiki is currently dedicated to dbachecks development.

Solid example

Below you will find a great example of our development standards

  • The parameter -Tags is pluralized
  • Actual tags are singular
  • The first Tag is unique, thereby "naming" the test LinkedServerConnection
  • The unique tag shows up as a unique tag in Get-DbcCheck

image

  • $psitem is used in lieu of $_
Describe "Linked Servers" -Tags LinkedServerConnection, Connectivity, $filename {
	(Get-SqlInstance).ForEach{
		Context "Testing Linked Servers on $psitem" {
			(Test-DbaLinkedServerConnection -SqlInstance $psitem).ForEach{
				It "Linked Server $($psitem.LinkedServerName) has connectivity" {
					$psitem.Connectivity | Should be $true
				}
			}
		}
	}
}

Context usage

Use context on database commands. Skip it on server commands. You can say "XYZ on $server is true"

Configuration System

This module relies on PSFramework for its infrastructure including the config system. The config system is mostly for end-user preferences, such as setting a static list of servers or skipping (internal) tests.

Users can skip entire tests by specifying the -ExcludeTag. Each test is automatically tagged with its file name (backups.Tests.ps1 -> backups).

Check out configuration.ps1

image

Each configuration must be "initialized" in this file and then any changes are persisted once the user executes Set-DbaConfig

Tags

Pester tags, like PowerShell command names and parameter names, are singular. Each command can have multiple tags such as Database, Restore and then the filename will also be attached as well.

Filenames

Lower case please, and in the checks folder

Auto completion (TEPP)

Auto-complete is provided by PSFramework. You can edit autocmplete.ps1 as required.

image

Clone this wiki locally