From bca0ad1cd2302535e9504a2397ad4e9fc96afe69 Mon Sep 17 00:00:00 2001 From: Kamil Nowinski Date: Wed, 1 Jul 2026 01:15:57 +0100 Subject: [PATCH] Added unit test for #475 --- changelog.md | 2 +- test/Publish-AdfV2FromJson-DryRun.Tests.ps1 | 54 +++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 test/Publish-AdfV2FromJson-DryRun.Tests.ps1 diff --git a/changelog.md b/changelog.md index be8ebf9..a4cb5b7 100644 --- a/changelog.md +++ b/changelog.md @@ -20,7 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixed * Starting blob event trigger fails with 'Resource cannot be updated during provisioning' - now waits for provisioning to complete before retrying #484, #474, #463 * Fixed REST API calls failing with 401 Unauthorized due to Az.Accounts 5.x returning SecureString from Get-AzAccessToken -* Fixed DryRun not loading deployment state from storage for hash comparison #476 +* Fixed DryRun not loading deployment state from storage for hash comparison #475 * README.md updated and new Structured Documentation created ## [1.14.0] - 2025-10-24 diff --git a/test/Publish-AdfV2FromJson-DryRun.Tests.ps1 b/test/Publish-AdfV2FromJson-DryRun.Tests.ps1 new file mode 100644 index 0000000..1da24b1 --- /dev/null +++ b/test/Publish-AdfV2FromJson-DryRun.Tests.ps1 @@ -0,0 +1,54 @@ +BeforeDiscovery { + $ModuleRootPath = $PSScriptRoot | Split-Path -Parent + $moduleManifestName = 'azure.datafactory.tools.psd1' + $moduleManifestPath = Join-Path -Path $ModuleRootPath -ChildPath $moduleManifestName + + Import-Module -Name $moduleManifestPath -Force -Verbose:$false + $m = Get-Module -Name 'azure.datafactory.tools' + $script:verStr = $m.Version.ToString(2) + "." + $m.Version.Build.ToString("000") +} + +InModuleScope azure.datafactory.tools { + $testHelperPath = $PSScriptRoot | Join-Path -ChildPath 'TestHelper' + Import-Module -Name $testHelperPath -Force + + $m = Get-Module -Name 'azure.datafactory.tools' + $script:verStr = $m.Version.ToString(2) + "." + $m.Version.Build.ToString("000") + + $script:RootFolder = Join-Path $PSScriptRoot 'adf2' + $script:ResourceGroupName = 'rg-test' + $script:DataFactoryName = 'adf-test' + $script:Location = 'West Europe' + + Describe 'Publish-AdfV2FromJson DryRun incremental deployment' -Tag 'Unit' { + BeforeEach { + Mock Get-StateFromStorage { + [AdfDeploymentState]::new($script:verStr) + } + + Mock Set-StateToStorage { + } + } + + It 'should still load deployment state from storage when DryRun is enabled' { + $opt = New-AdfPublishOption + $opt.IncrementalDeployment = $true + $opt.IncrementalDeploymentStorageUri = 'https://example.blob.core.windows.net/adftools/folder' + $opt.StopStartTriggers = $false + $opt.DeleteNotInSource = $false + + { + Publish-AdfV2FromJson ` + -RootFolder $script:RootFolder ` + -ResourceGroupName $script:ResourceGroupName ` + -DataFactoryName $script:DataFactoryName ` + -Location $script:Location ` + -Option $opt ` + -DryRun + } | Should -Not -Throw + + Should -Invoke -CommandName Get-StateFromStorage -Times 1 -Exactly + Should -Invoke -CommandName Set-StateToStorage -Times 0 -Exactly + } + } +} \ No newline at end of file