Skip to content

Commit 5473037

Browse files
authored
Merge pull request #170 from dataplat/development
v0.9.2
2 parents 15ace95 + ece1c86 commit 5473037

File tree

7 files changed

+18
-4
lines changed

7 files changed

+18
-4
lines changed

dbops.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
RootModule = '.\dbops.psm1'
55

66
# Version number of this module.
7-
ModuleVersion = '0.9.0'
7+
ModuleVersion = '0.9.1'
88

99
# ID used to uniquely identify this module
1010
GUID = '16dff216-533a-4fa3-9b2e-4408dbe15e63'

docs/changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Release notes for v0.9.2:
2+
- ### Check for empty file when computing hash (#168) by @matthiaslueken
13
# Release notes for v0.9.1:
24
- ### Update README.md (#156) by @kevchant
35
- ### adding AlwaysRollback to deploy.ps1 and module configuration (#157) by @nvarscar

internal/classes/DBOps.class.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,6 +1093,8 @@ class DBOpsFile : DBOps {
10931093
[void] RebuildHash() {
10941094
if ($this.Length -gt 0) {
10951095
$this.Hash = [DBOpsHelper]::ToHexString([Security.Cryptography.HashAlgorithm]::Create("MD5").ComputeHash($this.ByteArray))
1096+
} else {
1097+
$this.ThrowException("Hash cannot be computed, file is empty: $($this.Name)", 'InvalidData')
10961098
}
10971099
}
10981100
#Verify that hash is valid

internal/functions/Install-NugetPackage.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,13 @@ function Install-NugetPackage {
9595

9696
$baseAddressUrl = $index.resources | Where-Object { $_.'@type' -eq 'PackageBaseAddress/3.0.0' } | Select-Object -First 1
9797
$downloadUrl = "$($baseAddressUrl.'@id')$packageLowerName/$selectedVersion/$fileName"
98-
Invoke-WebRequest -Uri $downloadUrl -OutFile $packagePath -ErrorAction Stop
98+
try {
99+
Invoke-WebRequest -Uri $downloadUrl -OutFile $packagePath -ErrorAction Stop
100+
}
101+
catch {
102+
$originalError = $_.Exception.Message
103+
Stop-PSFFunction -Message "Failed to download from $downloadUrl`: $originalError" -EnableException $true
104+
}
99105
Write-PSFMessage -Level Verbose -Message "Extracting $fileName to $folder"
100106
if ($isCoreCLR) {
101107
[System.IO.Compression.ZipFile]::ExtractToDirectory($packagePath, $folder, $true)

tests/common/DBOpsFile.class.Tests.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ Describe "DBOpsFile class tests" -Tag UnitTests {
154154
$file.RebuildHash()
155155
$file.Hash | Should -Be $oldHash
156156
}
157+
It "should test RebuildHash method with empty file" {
158+
$emptyFile = New-Item $workFolder\emptyfile.sql -ItemType File
159+
{ [DBOpsFile]::new($emptyFile, 'emptyfile.sql', $true) } | Should -Throw
160+
}
157161
It "should test ValidateHash method" {
158162
$hash = $file.Hash
159163
{ $file.ValidateHash('foo') } | Should -Throw 'File cannot be loaded, hash mismatch*'

tests/compliance/InModule.Help.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ BeforeDiscovery {
33
$includedNames = (Get-ChildItem "$PSScriptRoot\..\..\functions" | Where-Object Name -like "*.ps1" ).BaseName
44
$commands = Get-Command -Module (Get-Module dbops) -CommandType Cmdlet, Function | Where-Object Name -in $includedNames
55
$commonParameters = 'Debug', 'ErrorAction', 'ErrorVariable', 'InformationAction', 'InformationVariable', 'OutBuffer', 'OutVariable',
6-
'PipelineVariable', 'Verbose', 'WarningAction', 'WarningVariable'
6+
'PipelineVariable', 'ProgressAction', 'Verbose', 'WarningAction', 'WarningVariable'
77
$testCases = $commands | ForEach-Object {
88
if ($global:FunctionHelpTestExceptions -contains $_.Name) { continue }
99
@{ Command = $_; CommandName = $_.Name; Help = Get-Help $_.Name -ErrorAction SilentlyContinue; Common = $commonParameters }

tests/integration/Install-NugetPackage.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Describe "Install-NugetPackage tests" -Tag IntegrationTests {
4040
It "should attempt to install $d libraries for a wrong version" {
4141
$dependencies = Get-ExternalLibrary -Type $Type
4242
foreach ($package in $dependencies) {
43-
{ Install-NugetPackage -Name $package.Name -RequiredVersion "0.somerandomversion" -Scope CurrentUser -Force -Confirm:$false } | Should -Throw '*Not Found*'
43+
{ Install-NugetPackage -Name $package.Name -RequiredVersion "0.somerandomversion" -Scope CurrentUser -Force -Confirm:$false } | Should -Throw 'Failed to download*'
4444
{ Install-NugetPackage -Name $package.Name -MinimumVersion "10.0" -MaximumVersion "1.0" -Scope CurrentUser -Force -Confirm:$false } | Should -Throw '*Version could not be found*'
4545
}
4646
}

0 commit comments

Comments
 (0)