99#
1010
1111$ModuleName = ' InstallModuleFromGit'
12- $here = Split-Path - Parent $MyInvocation.MyCommand.Path # test folder
13- $root = (get-item $here ).Parent.FullName # module root folder
12+ $here = Split-Path - Parent $MyInvocation.MyCommand.Path # Tests/Module folder
13+ $root = (get-item $here ).Parent.Parent. FullName # module root folder
1414Import-Module (Join-Path $root " $ModuleName .psm1" ) - Force
1515
1616
1717#
1818# Fake test
1919#
2020
21- Describe " Fake-Test" {
21+ Describe " Fake-Test" - Tag ' Other ' {
2222 It " Should be fixed by developer" {
2323 $true | Should - Be $true
2424 }
2525}
2626
2727
2828#
29- # Module should import two functions
29+ # Module manifest should have proper format
3030#
3131
32+ Describe ' Proper Module Declaration' - Tag ' Documentation' {
3233
33- Describe ' Proper Declarations' {
34+ $ModuleManifestFile = " $root /$ModuleName .psd1"
35+ It ' Module manifest can be parsed' {
36+ {Test-ModuleManifest $ModuleManifestFile } | Should -Not - Throw
37+ }
3438
35- It ' Checks for existence of functions' {
36- @ (Get-Command - Module $ModuleName - CommandType Function).Count | Should - Be 2 - Because ' We should have two functions defined'
37- Get-Command NonExistingCommand - ea 0 | Should - Be $Null
38- # cache management
39- Get-Command Get-GitModule - ea 0 | Should -Not - Be $Null
40- Get-Command Install-GitModule - ea 0 | Should -Not - Be $Null
39+ $ModuleManifest = Test-ModuleManifest $ModuleManifestFile
40+ $ModuleVersion = $ModuleManifest.Version
41+ It ' Module version must be x.y.z' {
42+ ($ModuleVersion.ToString () -split ' \.' ).Count -ge 3 | Should - Be $true - Because " Module with version $ModuleVersion cannot exist online"
4143 }
4244
45+ It " Checks online for module version $ModuleVersion " {
46+ Find-Module $ModuleName - Repository PSGallery - RequiredVersion $ModuleVersion - ea 0 | Should - Be $null
47+ }
4348}
4449
4550
4651#
47- # Basic tests, this should be added to individual files
52+ # Module should import two functions
4853#
4954
50- Describe ' Basic testing' {
51-
52- $moduleName = ' FIFA2018'
53- $moduleURL = ' https://github.com/iricigor/' + $moduleName
54- It ' Get-GitModule does not throw an exception' {
55- {Get-GitModule $moduleURL } | Should -Not - Throw
56- }
57-
58- It ' Get-GitModule returns some value' {
59- Get-GitModule $moduleURL | Should -Not - Be $null
60- }
61-
62- It ' Get-GitModule returns proper value' {
63- (Get-GitModule $moduleURL ).Name | Should - Be $moduleName
64- }
65-
66- $moduleName = ' psaptgetupdate'
67- $moduleURL = ' https://github.com/iricigor/' + $moduleName
68- It ' Install-GitModule does not throw an exception' {
69- {Install-GitModule $moduleURL - Force} | Should -Not - Throw
70- }
71-
72- It ' Install-GitModule returns some value' {
73- Install-GitModule $moduleURL - Force | Should -Not - Be $null
74- }
7555
76- It ' Install-GitModule returns proper value' {
77- (Install-GitModule $moduleURL - Force).Name | Should - Be $moduleName
78- }
56+ Describe ' Proper Functions Declaration' - Tag ' Other' {
7957
80- It ' Install-GitModule really installs module' {
81- Get-Module $moduleName - ListAvailable | Should -Not - Be $null
58+ It ' Checks for existence of functions' {
59+ @ (Get-Command - Module $ModuleName - CommandType Function).Count | Should - Be 2 - Because ' We should have two functions defined'
60+ Get-Command NonExistingCommand - ea 0 | Should - Be $Null
61+ Get-Command Get-GitModule - ea 0 | Should -Not - Be $Null
62+ Get-Command Install-GitModule - ea 0 | Should -Not - Be $Null
8263 }
8364}
8465
8566
86- Describe ' Proper Documentation' {
67+ Describe ' Proper Documentation' - Tag ' Documentation ' {
8768
8869 It ' Updates documentation and does git diff' {
8970
@@ -105,7 +86,7 @@ Describe 'Proper Documentation' {
10586}
10687
10788
108- Describe ' ScriptAnalyzer Tests' {
89+ Describe ' ScriptAnalyzer Tests' - Tag ' Documentation ' {
10990 it ' Checks cmdlets and finds no errors' {
11091 # Install PSScriptAnalyzer
11192 if (! (Get-Module PSScriptAnalyzer - List - ea 0 )) {Install-Module PSScriptAnalyzer - Force - Scope CurrentUser}
0 commit comments