Skip to content

Commit

Permalink
Merge pull request #20 from andrewrdavidson/release-1.0.10
Browse files Browse the repository at this point in the history
Release 1.0.10
  • Loading branch information
andrewrdavidson authored Jan 11, 2021
2 parents 9577cc9 + 16ee4bf commit 0f181b1
Show file tree
Hide file tree
Showing 46 changed files with 2,950 additions and 1,391 deletions.
50 changes: 38 additions & 12 deletions Checks/Function-Extraction.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,56 @@ param(
[string]$ExtractPath
)

Describe "Function Extraction" {
BeforeDiscovery {

if ( Test-Path -Path $ExtractPath ) {
Get-ChildItem -Path $ExtractPath -Recurse -ErrorAction SilentlyContinue | Remove-Item -Force -Recurse
Remove-Item $ExtractPath -Force -ErrorAction SilentlyContinue
}
$moduleFiles = @()

$Source | ForEach-Object {

New-Item -Path $ExtractPath -ItemType 'Directory'
$fileProperties = (Get-Item -Path $_)

foreach ($moduleFile in $Source) {
$moduleFiles += @{
'FullName' = $_
'Name' = $fileProperties.Name
'Directory' = $fileProperties.Directory

}

Context "Module : $moduleFile" {
}

It "function extraction should complete" -TestCases @{ 'moduleFile' = $moduleFile } {
}

{
Describe "Function Extraction" {

Export-FunctionsFromModule -Path $moduleFile -ExtractPath $ExtractPath
Context "Script: <_.Name> at <_.Directory>" -ForEach $moduleFiles {

} | Should -Not -Throw
BeforeAll {

if ( Test-Path -Path $ExtractPath ) {
Get-ChildItem -Path $ExtractPath -Recurse -ErrorAction SilentlyContinue | Remove-Item -Force -Recurse
Remove-Item $ExtractPath -Force -ErrorAction SilentlyContinue
}

New-Item -Path $ExtractPath -ItemType 'Directory'

}

BeforeEach {

$moduleFile = $_.FullName

}

It "function extraction should complete" {

{

Export-FunctionsFromModule -Path $moduleFile -ExtractPath $ExtractPath

} | Should -Not -Throw

}

}

}
83 changes: 46 additions & 37 deletions Checks/Module.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,70 +3,79 @@ param(
[string[]]$Source
)

BeforeDiscovery {

$moduleFiles = @()

$Source | ForEach-Object {

$fileProperties = (Get-Item -Path $_)

$moduleFiles += @{
'FullName' = $_
'Name' = $fileProperties.Name
'Directory' = $fileProperties.Directory

}

}

}

Describe "Module Tests" {

# TODO: Investigate whether the foreach can be put in the testcases block?
foreach ($moduleFile in $Source) {
Context "Script: <_.Name> at <_.Directory>" -ForEach $moduleFiles {

Context "Module : $moduleFile" {
BeforeEach {

$manifestFile = [Io.Path]::ChangeExtension($moduleFile, 'psd1')
$moduleFile = $_.FullName
$manifestFile = [Io.Path]::ChangeExtension($_.FullName, 'psd1')

It "Module should exist" -TestCases @{ 'moduleFile' = $moduleFile } {
($ExportedCommandsCount, $CommandFoundInModuleCount, $CommandInModuleCount, $CommandFoundInManifestCount) = Get-FunctionCount -Module $moduleFile -Manifest $manifestFile

$moduleFile | Should -Exist
}

}
It "Module should exist" {

It "Manifest should exist" -TestCases @{ 'manifestFile' = $manifestFile } {
$moduleFile | Should -Exist

$manifestFile | Should -Exist
}

}
It "Manifest should exist" {

It "Manifest should be valid" -TestCases @{ 'manifestFile' = $manifestFile } {
$manifestFile | Should -Exist

$manifest = Test-ModuleManifest -Path $manifestFile -ErrorAction SilentlyContinue
}

$manifest | Should -BeOfType [System.Management.Automation.PSModuleInfo]
It "Manifest should be valid" {

}
$manifest = Test-ModuleManifest -Path $manifestFile -ErrorAction SilentlyContinue

($ExportedCommandsCount, $CommandFoundInModuleCount, $CommandInModuleCount, $CommandFoundInManifestCount) = Get-FunctionCount -Module $moduleFile -Manifest $manifestFile
$manifest | Should -BeOfType [System.Management.Automation.PSModuleInfo]

It "Manifest should export Functions" -TestCases @{
'ExportedCommandsCount' = $ExportedCommandsCount
} {
}

($ExportedCommandsCount) | Should -BeGreaterOrEqual 1
It "Manifest should export Functions" {

}
($ExportedCommandsCount) | Should -BeGreaterOrEqual 1

It "Module should have Functions" -TestCases @{
'CommandInModuleCount' = $CommandInModuleCount
} {
}

($CommandInModuleCount) | Should -BeGreaterOrEqual 1
It "Module should have Functions" {

}
($CommandInModuleCount) | Should -BeGreaterOrEqual 1

It "all exported Functions from Manifest should exist in the Module" -TestCases @{
'ExportedCommandsCount' = $ExportedCommandsCount
'CommandFoundInModuleCount' = $CommandFoundInModuleCount
} {
}

($ExportedCommandsCount -eq $CommandFoundInModuleCount -and $ExportedCommandsCount -ge 1) | Should -BeTrue
It "all exported Functions from Manifest should exist in the Module" {

}
($ExportedCommandsCount -eq $CommandFoundInModuleCount -and $ExportedCommandsCount -ge 1) | Should -BeTrue

It "all Functions in the Module should exist in Manifest " -TestCases @{
'CommandInModuleCount' = $CommandInModuleCount
'CommandFoundInManifestCount' = $CommandFoundInManifestCount
} {
}

($CommandInModuleCount -eq $CommandFoundInManifestCount -and $CommandFoundInManifestCount -ge 1 ) | Should -BeTrue
It "all Functions in the Module should exist in Manifest " {

}
($CommandInModuleCount -eq $CommandFoundInManifestCount -and $CommandFoundInManifestCount -ge 1 ) | Should -BeTrue

}

Expand Down
Loading

0 comments on commit 0f181b1

Please sign in to comment.