reworked class importing, passing pester tests skip ci

This commit is contained in:
KevinMarquette
2017-02-04 20:53:08 -08:00
parent f532089ada
commit af7e4143cc
5 changed files with 47 additions and 14 deletions

View File

@@ -2,9 +2,10 @@ $projectRoot = Resolve-Path "$PSScriptRoot\.."
$moduleRoot = Split-Path (Resolve-Path "$projectRoot\*\*.psm1")
$moduleName = Split-Path $moduleRoot -Leaf
Import-Module (Join-Path $moduleRoot "$moduleName.psm1") -force
Describe "Help tests for $moduleName" -Tags Build {
Import-Module (Join-Path $moduleRoot "$moduleName.psm1") -force
$functions = Get-Command -Module $moduleName
$help = $functions | %{Get-Help $_.name}

View File

@@ -4,7 +4,7 @@ $moduleName = Split-Path $moduleRoot -Leaf
Describe "General project validation: $moduleName" -Tags Build {
$scripts = Get-ChildItem $projectRoot -Include *.ps1,*.psm1,*.psd1 -Recurse
$scripts = Get-ChildItem $projectRoot -Include *.ps1,*.psm1,*.psd1 -Recurse | where fullname -notmatch 'classes'
# TestCases are splatted to the script so we need hashtables
$testCase = $scripts | Foreach-Object{@{file=$_}}
@@ -19,6 +19,18 @@ Describe "General project validation: $moduleName" -Tags Build {
$errors.Count | Should Be 0
}
It "Classes are valid" {
$classes = Get-ChildItem $projectRoot -Include *.ps1,*.psm1,*.psd1 -Recurse | where fullname -match 'classes'
# Must be imported togehter incase they depend on each other
$contents = Get-Content -Path $classes.FullName | Out-String
$errors = $null
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
$errors.Count | Should Be 0
}
It "Module '$moduleName' can import cleanly" {
{Import-Module (Join-Path $moduleRoot "$moduleName.psm1") -force } | Should Not Throw
}

View File

@@ -2,12 +2,13 @@ $projectRoot = Resolve-Path "$PSScriptRoot\.."
$moduleRoot = Split-Path (Resolve-Path "$projectRoot\*\*.psd1")
$moduleName = Split-Path $moduleRoot -Leaf
Import-Module (Join-Path $moduleRoot "$moduleName.psm1") -force
Describe "Basic unit tests" -Tags Build {
Import-Module (Join-Path $moduleRoot "$moduleName.psm1") -force
Context "Function: Get-Chronometer" {
it "Does not throw" {
# Get-Chronometer -Path ScratchFiles\example.ps1 -Script {"Test"}
{Get-Chronometer -Path $PSScriptRoot\..\ScratchFiles\example.ps1 -Script {"Test"} } | Should Not Throw
}
}