Skip to content

Commit 870e7b4

Browse files
committed
extended readme, basic tests
1 parent 7dc07a3 commit 870e7b4

6 files changed

Lines changed: 388 additions & 5 deletions

File tree

Docs/Get-GitModule.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ Accept wildcard characters: False
7676
```
7777
7878
### CommonParameters
79-
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
80-
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
79+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
8180
8281
## INPUTS
8382

Docs/Install-GitModule.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ Accept wildcard characters: False
9292
```
9393
9494
### CommonParameters
95-
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
96-
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
95+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
9796
9897
## INPUTS
9998

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,37 @@
22

33
Helps installing modules directly from GitHub or Azure DevOps
44

5+
## Prerequisites
6+
7+
* **git** - it must be installed and available on path
8+
59
## Installation
610

11+
### clone GitHub repository
12+
13+
```PowerShell
14+
git clone https://github.com/iricigor/InstallGitModule
15+
Import-Module ./InstallGitModule/InstallGitModule.psd1
16+
```
17+
18+
### from PowerShell gallery
19+
20+
_(not yet available)_
21+
22+
## Examples
23+
24+
```PowerShell
25+
C:> Get-GitModule 'https://github.com/iricigor/FIFA2018' -Verbose
26+
27+
C:> Install-GitModule 'https://github.com/iricigor/psaptgetupdate' | Select -Expand Name | Import-Module
28+
```
29+
30+
## Commands
31+
32+
### Get-GitModule
33+
34+
### Install-GitModule
35+
736
## Similar versions
837

9-
https://github.com/dfinke/InstallModuleFromGitHub/blob/master/InstallModuleFromGitHub.psm1
38+
[dfinke](https://github.com/dfinke)/[InstallModuleFromGitHub](https://github.com/dfinke/InstallModuleFromGitHub)

Tests/Get-GitModule.Tests.ps1

Whitespace-only changes.

Tests/Module.Tests.ps1

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#
2+
# This is a PowerShell Unit Test file.
3+
# You need a unit test framework such as Pester to run PowerShell Unit tests.
4+
# You can download Pester from http://go.microsoft.com/fwlink/?LinkID=534084
5+
#
6+
7+
#
8+
# Import module
9+
#
10+
11+
$ModuleName = 'InstallGitModule'
12+
$here = Split-Path -Parent $MyInvocation.MyCommand.Path # test folder
13+
$root = (get-item $here).Parent.FullName # module root folder
14+
Import-Module (Join-Path $root "$ModuleName.psm1") -Force
15+
16+
17+
#
18+
# Fake test
19+
#
20+
21+
Describe "Fake-Test" {
22+
It "Should be fixed by developer" {
23+
$true | Should -Be $true
24+
}
25+
}
26+
27+
28+
#
29+
# Module should import six functions
30+
#
31+
32+
33+
Describe 'Proper Declarations' {
34+
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
41+
}
42+
43+
}
44+
45+
46+
Describe 'Proper Documentation' {
47+
48+
It 'Updates documentation and does git diff' {
49+
50+
# install PlatyPS
51+
# Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
52+
if (!(Get-Module platyPS -List -ea 0)) {Install-Module platyPS -Force -Scope CurrentUser}
53+
Import-Module platyPS
54+
55+
# update documentation
56+
Push-Location -Path $root
57+
Update-MarkdownHelp -Path .\Docs
58+
New-ExternalHelp -Path .\Docs -OutputPath .\en-US -Force
59+
60+
# test it
61+
$diff = git diff .\Docs .\en-US
62+
Pop-Location
63+
$diff | Should -Be $null
64+
}
65+
}
66+
67+
68+
Describe 'ScriptAnalyzer Tests' {
69+
it 'Checks cmdlets and finds no errors' {
70+
# Install PSScriptAnalyzer
71+
if (!(Get-Module PSScriptAnalyzer -List -ea 0)) {Install-Module PSScriptAnalyzer -Force -Scope CurrentUser}
72+
Import-Module PSScriptAnalyzer
73+
# Check code
74+
$SA = Invoke-ScriptAnalyzer -Path $root -Recurse
75+
$SA | where Severity -eq 'Error' | Should -Be $null
76+
}
77+
}

0 commit comments

Comments
 (0)