tests/dbatools.Tests.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
$Path = Split-Path -Parent $MyInvocation.MyCommand.Path
$ModulePath = (get-item $Path ).parent.FullName
$ModuleName = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -Replace ".Tests.ps1"
$ManifestPath   = "$ModulePath\$ModuleName.psd1"


# test the module manifest - exports the right functions, processes the right formats, and is generally correct

Describe "Manifest" {

    $Manifest = $null

    It "has a valid manifest" {

        {

            $Script:Manifest = Test-ModuleManifest -Path $ManifestPath -ErrorAction Stop -WarningAction SilentlyContinue

        } | Should Not Throw

    }
## Should be fixed now - Until the issue with requiring full paths for required assemblies is resolved need to keep this commented out RMS 01112016

$Script:Manifest = Test-ModuleManifest -Path $ManifestPath -ErrorAction SilentlyContinue
    It "has a valid name" {

        $Script:Manifest.Name | Should Be $ModuleName

    }



    It "has a valid root module" {

        $Script:Manifest.RootModule | Should Be "$ModuleName.psm1"

    }



    It "has a valid Description" {

        $Script:Manifest.Description | Should Be 'Provides extra functionality for SQL Server Database admins and enables SQL Server instance migrations.'

    }

    It "has a valid Author" {
        $Script:Manifest.Author | Should Be 'Chrissy LeMaire'
    }

    It "has a valid Company Name" {
        $Script:Manifest.CompanyName | Should Be 'dbatools.io'
    }
    It "has a valid guid" {

        $Script:Manifest.Guid | Should Be '9d139310-ce45-41ce-8e8b-d76335aa1789'

    }
    It "has valid PowerShell version" {
        $Script:Manifest.PowerShellVersion | Should Be '3.0'
    }

    It "has valid required assemblies" {
        {$Script:Manifest.RequiredAssemblies -eq @()} | Should Be $true
    }

    It "has a valid copyright" {

        $Script:Manifest.CopyRight | Should BeLike '* Chrissy LeMaire'

    }


<#
 # Don't want this just yet
 
    It 'exports all public functions' {
 
        $FunctionFiles = Get-ChildItem "$ModulePath\functions" -Filter *.ps1 | Select -ExpandProperty BaseName
 
        $FunctionNames = $FunctionFiles
 
        $ExFunctions = $Script:Manifest.ExportedFunctions.Values.Name
        $ExFunctions
        foreach ($FunctionName in $FunctionNames)
 
        {
 
            $ExFunctions -contains $FunctionName | Should Be $true
 
        }
 
    }
#>


}