From 6e2def9b710c78dfd0e8d7db1cd220935543f363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bere=C5=BCa=C5=84ski?= Date: Sat, 14 Jun 2014 00:46:06 +0200 Subject: [PATCH 1/3] fix invalid copyright character In commit dcfb750, the copyright character (Windows-1252 0xA9) somehow got replaced with three bytes EF BF BD, which, despite resembling UTF-8, do not encode a valid Unicode codepoint (U+FDFF is undefined). Replace those bytes with simple ASCII (c) to keep Chocolatey code character set as generic as possible. --- chocolateyInstall/InstallChocolatey.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chocolateyInstall/InstallChocolatey.ps1 b/chocolateyInstall/InstallChocolatey.ps1 index 82c0157..a3a27cd 100644 --- a/chocolateyInstall/InstallChocolatey.ps1 +++ b/chocolateyInstall/InstallChocolatey.ps1 @@ -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. # From 4cc7dd4f2b60aa01843fdbe2301ff42194207a8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bere=C5=BCa=C5=84ski?= Date: Sat, 14 Jun 2014 00:46:33 +0200 Subject: [PATCH 2/3] replace Unicode en dashes with ASCII minus signs En dashes (U+2013) usually appear when writing code snippets in word processors or html editors, which make an effort to replace minus signs with nicer looking en and em dashes. Nicer for text documents, but not for code. PowerShell actually tolerates en dashes, but some text manipulation tools do not. Moreover, those are the only symbols outside of ASCII charset in Chocolatey code. Replace them with standard minus signs. --- src/functions/Chocolatey-Version.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/functions/Chocolatey-Version.ps1 b/src/functions/Chocolatey-Version.ps1 index 8e92c19..ceeef04 100644 --- a/src/functions/Chocolatey-Version.ps1 +++ b/src/functions/Chocolatey-Version.ps1 @@ -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 } @@ -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 } } From 465710408a8c52fd270ac56f1275bd132f1122c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bere=C5=BCa=C5=84ski?= Date: Thu, 26 Jun 2014 23:08:39 +0200 Subject: [PATCH 3/3] add basic smoke tests for Chocolatey-Version --- tests/unit/Chocolatey-Version.tests.ps1 | 35 +++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/unit/Chocolatey-Version.tests.ps1 diff --git a/tests/unit/Chocolatey-Version.tests.ps1 b/tests/unit/Chocolatey-Version.tests.ps1 new file mode 100644 index 0000000..98f56bf --- /dev/null +++ b/tests/unit/Chocolatey-Version.tests.ps1 @@ -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+(-.+)?$' + } + } + +}