Skip to content
This repository has been archived by the owner on Feb 19, 2019. It is now read-only.

Fix non-ASCII characters + add Chocolatey-Version tests #497

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion chocolateyInstall/InstallChocolatey.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ==============================================================================
#
# Fervent Coder Copyright 2011 - Released under the Apache 2.0 License
# Fervent Coder Copyright (c) 2011 - Released under the Apache 2.0 License
#
# Copyright 2007-2008 The Apache Software Foundation.
#
Expand Down
6 changes: 3 additions & 3 deletions src/functions/Chocolatey-Version.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ param(
}

$versionFound = ''
$versionsObj = New-Object typename PSObject
$versionsObj = New-Object -typename PSObject
foreach ($package in $packages.GetEnumerator()) {
$packageName = $package.Name
if ($packageName -eq '') { continue }
Expand Down Expand Up @@ -66,11 +66,11 @@ param(
}

$versions = @{name=$($package.Name); latest = $versionLatest; found = $versionFound; latestCompare = $versionLatestCompare; foundCompare = $versionFoundCompare; verMessage = $verMessage}
$versionsObj = New-Object typename PSObject -Property $versions
$versionsObj = New-Object -typename PSObject -Property $versions
$versionsObj
} else {
$versions = @{name=$($package.Name); found = $versionFound}
$versionsObj = New-Object typename PSObject -Property $versions
$versionsObj = New-Object -typename PSObject -Property $versions
$versionsObj
}
}
Expand Down
35 changes: 35 additions & 0 deletions tests/unit/Chocolatey-Version.tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
$here = Split-Path -Parent $MyInvocation.MyCommand.Definition
$common = Join-Path (Split-Path -Parent $here) '_Common.ps1'
. $common

# neither nuget.exe nor Process.Start() will understand TestDrive:\
$nugetLibPath = (Resolve-Path $nugetLibPath).ProviderPath
$nugetExe = "$src\nuget.exe"

Describe "Chocolatey-Version" {

Context "When called for nonexistent package" {
Setup -Dir 'chocolatey\chocolateyInstall'
Copy-Item $src\chocolatey.config $nugetChocolateyPath -Force

It "should throw an exception" {
{ Chocolatey-Version 'nonexistent-package' } | Should Throw
}
}

Context "When called with no arguments" {
Setup -Dir 'chocolatey\chocolateyInstall'
Copy-Item $src\chocolatey.config $nugetChocolateyPath -Force

It "should not throw an exception" {
{ $script:output = Chocolatey-Version } | Should not Throw
Write-Debug "Chocolatey-Version output: $script:output"
}
It "should return version of chocolatey" {
$script:output | Should not BeNullOrEmpty
($script:output).name | Should Be 'chocolatey'
($script:output).found | Should Match '^(\d+\.){3}\d+(-.+)?$'
}
}

}