Skip to content

Commit

Permalink
Merge pull request #24 from xtqqczze/lint
Browse files Browse the repository at this point in the history
Fix casing and typo
  • Loading branch information
jdhitsolutions authored Jul 30, 2020
2 parents eaa3cef + f83f44b commit 5b7badd
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 146 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Install-Module PSReleaseTools
On PowerShell you might need to run:

```powershell
Install-Module PSReleaseTools [-scope currentuser]
Install-Module PSReleaseTools [-Scope CurrentUser]
```

## Support
Expand Down
42 changes: 21 additions & 21 deletions Tests/PSReleaseTools.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,94 +3,94 @@ Remove-Module PSReleaseTools -ErrorAction SilentlyContinue
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$modRoot = Split-Path -Parent $here | Convert-Path

Write-Host "Importing module from $script:modroot" -ForegroundColor magenta
Write-Host "Importing module from $script:modroot" -ForegroundColor Magenta
Import-Module $modRoot -Force

InModuleScope PSReleaseTools {

$modPath = Get-Module psreleasetools | Select-Object path | Split-Path
$modPath = Get-Module PSReleaseTools | Select-Object path | Split-Path
Describe PSReleaseTools {
It "Has exported commands" {
{Get-Command -Module PSReleaseTools} | Should Be $true
{Get-Command -Module PSReleaseTools} | Should -Be $true
}

It "Has a README.md file" {
$f = Get-Item -Path $(Join-path -path $modpath -childpath README.md)
$f.name | Should Be "readme.md"
$f = Get-Item -Path $(Join-Path -Path $modpath -ChildPath README.md)
$f.name | Should -Be "readme.md"
}
Context Manifest {

It "Has a manifest" {
Get-Item -Path $modpath\PSReleaseTools.psd1 | Should Be $True
Get-Item -Path $modpath\PSReleaseTools.psd1 | Should -Be $true
}

It "Has a license URI" {
(Get-Module psreleasetools).PrivateData["PSData"]["LicenseUri"] | Should be $True
(Get-Module PSReleaseTools).PrivateData["PSData"]["LicenseUri"] | Should -Be $true
}

It "Has a project URI" {
(Get-Module psreleasetools).PrivateData["PSData"]["ProjectUri"] | Should be $True
(Get-Module PSReleaseTools).PrivateData["PSData"]["ProjectUri"] | Should -Be $true
}
} #context
}

Describe Get-PSReleaseAsset {
It "Runs without error" {
{$script:data = Get-PSReleaseAsset -ErrorAction Stop} | Should Not Throw
{$script:data = Get-PSReleaseAsset -ErrorAction Stop} | Should -Not -Throw
}
It "Writes one or more objects to the pipeline" {
$script:data.count | Should beGreaterThan 1
$script:data.count | Should -BeGreaterThan 1
}

$FamilyValues = (Get-Command Get-PSReleaseAsset).Parameters["Family"].Attributes.ValidValues
It "Has a validation set for Family" {
$FamilyValues.count | Should Be 12
$FamilyValues.count | Should -Be 12
}

It "Should fail with a bad Family value" {
{Get-PSReleaseAsset -Family FOO -ErrorAction} | Should Throw
{Get-PSReleaseAsset -Family FOO -ErrorAction} | Should -Throw
}
It "Should get release assets for Ubuntu" {
$script:dl = Get-PSReleaseAsset -Family Ubuntu
($script:dl).Count | Should beGreaterThan 0
($script:dl).Count | Should -BeGreaterThan 0
}

It "Result should have a Filename property" {
($script:dl)[0].Filename | Should Be $True
($script:dl)[0].Filename | Should -Be $true
}

It "Result should have an URL property with https" {
($Script:dl)[0].url | Should Match "^https"
($Script:dl)[0].URL | Should -Match "^https"
}

It "Result should have an [int] SizeMB property" {
($script:dl)[0].sizeMB | Should BeOfType "System.Int32"
($script:dl)[0].SizeMB | Should -BeOfType "System.Int32"
}
}

Describe Get-PSReleaseSummary {
It "Runs without error" {
{$script:sum = Get-PSReleaseSummary -ErrorAction Stop} | Should Not Throw
{$script:sum = Get-PSReleaseSummary -ErrorAction Stop} | Should -Not -Throw
}
It "Writes a string to the pipeline" {
$script:sum.getType().Name | Should Be "string"
$script:sum.GetType().Name | Should -Be "string"
}
}

Describe Save-PSReleaseAsset {
It "Has no tests defined at this time." {
$true | should be $True
$true | Should -Be $true
}
}
Describe Install-PSPreview {
It "Has no tests defined at this time." {
$true | should be $True
$true | Should -Be $true
}
}

Describe Install-PSCore {
It "Has no tests defined at this time." {
$true | should be $True
$true | Should -Be $true
}
}
}
54 changes: 27 additions & 27 deletions functions/private.ps1
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
#these are internal functions for the PSReleaseTools module

#define an internal function to download the file
Function DL {
[cmdletbinding(SupportsShouldProcess)]
Param([string]$Source, [string]$Destination, [string]$hash, [switch]$Passthru)
function DL {
[CmdletBinding(SupportsShouldProcess)]
param([string]$Source, [string]$Destination, [string]$Hash, [switch]$Passthru)

Write-Verbose "[$((Get-Date).TimeofDay) $($myinvocation.mycommand)] $Source to $Destination"
Write-Verbose "[$((Get-Date).TimeofDay) $($MyInvocation.MyCommand)] $Source to $Destination"

if ($pscmdlet.ShouldProcess($Destination, "Downloading $source")) {
Invoke-Webrequest -Uri $source -UseBasicParsing -DisableKeepAlive -OutFile $Destination
Write-Verbose "[$((Get-Date).TimeofDay) $($myinvocation.mycommand)] Comparing file hash to $hash"
if ($PSCmdlet.ShouldProcess($Destination, "Downloading $Source")) {
Invoke-WebRequest -Uri $source -UseBasicParsing -DisableKeepAlive -OutFile $Destination
Write-Verbose "[$((Get-Date).TimeofDay) $($MyInvocation.MyCommand)] Comparing file hash to $Hash"
$f = Get-FileHash -Path $Destination -Algorithm SHA256
if ($f.hash -ne $hash) {
if ($f.Hash -ne $Hash) {
Write-Warning "Hash mismatch. $Destination may be incomplete."
}

if ($passthru) {
if ($Passthru) {
Get-Item $Destination
}
} #should process
} #DL

Function GetData {
[cmdletbinding()]
Param(
function GetData {
[CmdletBinding()]
param(
[switch]$Preview
)

$uri = "https://api.github.com/repos/powershell/powershell/releases"

Write-Verbose "[$((Get-Date).TimeofDay) $($myinvocation.mycommand)] Getting current release information from $uri"
$get = Invoke-Restmethod -uri $uri -Method Get -ErrorAction stop
Write-Verbose "[$((Get-Date).TimeofDay) $($MyInvocation.MyCommand)] Getting current release information from $uri"
$get = Invoke-RestMethod -Uri $uri -Method Get -ErrorAction Stop

if ($Preview) {
Write-Verbose "[$((Get-Date).TimeofDay) $($myinvocation.mycommand)] Getting latest preview"
($get).where( {$_.prerelease}) | Select-Object -first 1
Write-Verbose "[$((Get-Date).TimeofDay) $($MyInvocation.MyCommand)] Getting latest preview"
($get).where( {$_.prerelease}) | Select-Object -First 1
}
else {
Write-Verbose "[$((Get-Date).TimeofDay) $($myinvocation.mycommand)] Getting latest stable release"
($get).where( { -NOT $_.prerelease}) | Select-Object -first 1
Write-Verbose "[$((Get-Date).TimeofDay) $($MyInvocation.MyCommand)] Getting latest stable release"
($get).where( { -NOT $_.prerelease}) | Select-Object -First 1
}
}

Function InstallMsi {
[cmdletbinding(SupportsShouldProcess)]
Param(
function InstallMsi {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory, HelpMessage = "The full path to the MSI file")]
[ValidateScript({Test-Path $_})]
[string]$Path,
Expand All @@ -57,7 +57,7 @@ Function InstallMsi {
[switch]$EnableContextMenu
)

Write-Verbose "[$((Get-Date).TimeofDay) $($myinvocation.mycommand)] Creating Start-Process parameters"
Write-Verbose "[$((Get-Date).TimeofDay) $($MyInvocation.MyCommand)] Creating Start-Process parameters"

$modeOption = switch ($Mode) {
"Full" {"/qf" }
Expand All @@ -74,14 +74,14 @@ Function InstallMsi {
$installOption += " ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1"
}

Write-Verbose "[$((Get-Date).TimeofDay) $($myinvocation.mycommand)] FilePath: $Path"
Write-Verbose "[$((Get-Date).TimeofDay) $($myinvocation.mycommand)] ArgumentList: $installOption"
Write-Verbose "[$((Get-Date).TimeofDay) $($MyInvocation.MyCommand)] FilePath: $Path"
Write-Verbose "[$((Get-Date).TimeofDay) $($MyInvocation.MyCommand)] ArgumentList: $installOption"

if ($pscmdlet.ShouldProcess("$Path $installOption")) {
Write-Verbose "[$((Get-Date).TimeofDay) $($myinvocation.mycommand)] Starting installation process"
if ($PSCmdlet.ShouldProcess("$Path $installOption")) {
Write-Verbose "[$((Get-Date).TimeofDay) $($MyInvocation.MyCommand)] Starting installation process"
Start-Process -FilePath $Path -ArgumentList $installOption
}

Write-Verbose "[$((Get-Date).TimeofDay) $($myinvocation.mycommand)] Ending function"
Write-Verbose "[$((Get-Date).TimeofDay) $($MyInvocation.MyCommand)] Ending function"

} #close installmsi
Loading

0 comments on commit 5b7badd

Please sign in to comment.