Skip to content

Commit 32a05fa

Browse files
authored
Merge pull request #127 from SQLPlayer/bug125
Fixed `Test-AdfCode` when validating empty factory #125
2 parents e593ed4 + adafbbe commit 32a05fa

File tree

6 files changed

+37
-2
lines changed

6 files changed

+37
-2
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ The main advantage of the module is the ability to publish all the Azure Data Fa
2323
* Tokenisation in config file allows replace any value by Environment Variable or Variable from DevOps Pipeline
2424
* (new!) Allows to define multiple file (objects) by wildcarding
2525
* Global Parameters
26-
26+
* Support for Managed VNET and Managed Private Endpoint (new!)
27+
2728
The following features coming in the future:
2829
* Build function to support validation of files, dependencies and config
2930
* Unit Tests of selected Pipelines and Linked Services

azure.datafactory.tools.psd1

0 Bytes
Binary file not shown.

changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

7+
## [0.75.0] - 2021-08-05
8+
* Fixed `Test-AdfCode` when validating empty factory #125
9+
710
## [0.74.0] - 2021-08-03
811
* Cmdlet `Test-AdfCode` validates config files #62
912
* Support configuration for Managed Private Endpoint #95

public/Test-AdfCode.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function Test-AdfCode {
8484
}
8585
}
8686

87-
if ($adf.Factories.Count -gt 0) {
87+
if ($adf.Factories.Count -gt 0 -and (Get-Member -InputObject $adf.Factories[0].Body -name "properties" -Membertype "Properties")) {
8888
Get-Member -InputObject $adf.Factories[0].Body.properties.globalParameters -Membertype "NoteProperty" | ForEach-Object {
8989
[string] $name = $_.Name
9090
if ($name.Contains('-')) {
@@ -98,9 +98,11 @@ function Test-AdfCode {
9898
Write-Host "=== Validating config files ..."
9999
if (!$ConfigPath) {
100100
$filePattern = Join-Path -Path $adf.Location -ChildPath 'deployment\*'
101+
if (!(Test-Path $filePattern)) { $filePattern = $null }
101102
} else {
102103
$filePattern = $ConfigPath -split ','
103104
}
105+
104106
$files = Get-ChildItem -Path $filePattern -Include '*.csv','*.json'
105107
$err = $null
106108
$adf.PublishOptions.FailsWhenConfigItemNotFound = $True

test/Test-AdfCode.Tests.ps1

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
BeforeDiscovery {
2+
$ModuleRootPath = $PSScriptRoot | Split-Path -Parent
3+
$moduleManifestName = 'azure.datafactory.tools.psd1'
4+
$moduleManifestPath = Join-Path -Path $ModuleRootPath -ChildPath $moduleManifestName
5+
6+
Import-Module -Name $moduleManifestPath -Force -Verbose:$false
7+
}
8+
9+
InModuleScope azure.datafactory.tools {
10+
$testHelperPath = $PSScriptRoot | Join-Path -ChildPath 'TestHelper'
11+
Import-Module -Name $testHelperPath -Force
12+
13+
# Variables for use in tests
14+
15+
Describe 'Test-AdfCode' -Tag 'Unit' {
16+
It 'Should run successfully even for empty factory' {
17+
$DataFactoryName = "emptyFactory"
18+
$RootFolder = Join-Path -Path $PSScriptRoot -ChildPath $DataFactoryName
19+
{ Test-AdfCode $RootFolder } | Should -Not -Throw
20+
}
21+
22+
23+
24+
}
25+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "emptyFactory",
3+
"location": "EastUS"
4+
}

0 commit comments

Comments
 (0)