-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use default values for variables (#123)
fix: default values for variables
- Loading branch information
Showing
5 changed files
with
258 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
tests/functional/variables_default_value/pipeline/default_variables.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
{ | ||
"name": "default_variables", | ||
"properties": { | ||
"activities": [ | ||
{ | ||
"name": "Set outputStringVar", | ||
"type": "SetVariable", | ||
"dependsOn": [], | ||
"policy": { | ||
"secureOutput": false, | ||
"secureInput": false | ||
}, | ||
"userProperties": [], | ||
"typeProperties": { | ||
"variableName": "pipelineReturnValue", | ||
"value": [ | ||
{ | ||
"key": "outputStringVar", | ||
"value": { | ||
"type": "Expression", | ||
"content": "@if(equals(variables('stringVar'), null), 'is null', concat('is not null: ', variables('stringVar')))\n" | ||
} | ||
} | ||
], | ||
"setSystemVariable": true | ||
} | ||
}, | ||
{ | ||
"name": "Set outputIntVar", | ||
"type": "SetVariable", | ||
"dependsOn": [], | ||
"policy": { | ||
"secureOutput": false, | ||
"secureInput": false | ||
}, | ||
"userProperties": [], | ||
"typeProperties": { | ||
"variableName": "pipelineReturnValue", | ||
"value": [ | ||
{ | ||
"key": "outputIntVar", | ||
"value": { | ||
"type": "Expression", | ||
"content": "@if(equals(variables('intVar'), null), 'is null', concat('is not null: ', variables('intVar')))\n" | ||
} | ||
} | ||
], | ||
"setSystemVariable": true | ||
} | ||
}, | ||
{ | ||
"name": "Set outputBoolVar", | ||
"type": "SetVariable", | ||
"dependsOn": [], | ||
"policy": { | ||
"secureOutput": false, | ||
"secureInput": false | ||
}, | ||
"userProperties": [], | ||
"typeProperties": { | ||
"variableName": "pipelineReturnValue", | ||
"value": [ | ||
{ | ||
"key": "outputBoolVar", | ||
"value": { | ||
"type": "Expression", | ||
"content": "@if(equals(variables('boolVar'), null), 'is null', concat('is not null: ', variables('boolVar')))\n" | ||
} | ||
} | ||
], | ||
"setSystemVariable": true | ||
} | ||
}, | ||
{ | ||
"name": "Set outputArrayVar", | ||
"type": "SetVariable", | ||
"dependsOn": [], | ||
"policy": { | ||
"secureOutput": false, | ||
"secureInput": false | ||
}, | ||
"userProperties": [], | ||
"typeProperties": { | ||
"variableName": "pipelineReturnValue", | ||
"value": [ | ||
{ | ||
"key": "outputArrayVar", | ||
"value": { | ||
"type": "Expression", | ||
"content": "@if(equals(variables('arrayVar'), null), 'is null', concat('is not null: ', variables('arrayVar')))\n" | ||
} | ||
} | ||
], | ||
"setSystemVariable": true | ||
} | ||
} | ||
], | ||
"variables": { | ||
"stringVar": { | ||
"type": "String" | ||
}, | ||
"intVar": { | ||
"type": "Integer" | ||
}, | ||
"boolVar": { | ||
"type": "Boolean" | ||
}, | ||
"arrayVar": { | ||
"type": "Array" | ||
} | ||
}, | ||
"annotations": [] | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
tests/functional/variables_default_value/test_variables_default.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import pytest | ||
from data_factory_testing_framework import TestFramework, TestFrameworkType | ||
|
||
|
||
def test_string_default_variables(request: pytest.FixtureRequest) -> None: | ||
# Arrange | ||
test_framework = TestFramework( | ||
framework_type=TestFrameworkType.DataFactory, root_folder_path=request.fspath.dirname | ||
) | ||
pipeline = test_framework.get_pipeline_by_name("default_variables") | ||
|
||
# Act | ||
activities = test_framework.evaluate_pipeline( | ||
pipeline, | ||
[], | ||
) | ||
|
||
# Assert | ||
activity = next(activities) | ||
assert activity.name == "Set outputStringVar" | ||
assert activity.type_properties["value"][0]["key"] == "outputStringVar" | ||
assert activity.type_properties["value"][0]["value"].result == "is not null: " | ||
|
||
activity = next(activities) | ||
assert activity.name == "Set outputIntVar" | ||
assert activity.type_properties["value"][0]["key"] == "outputIntVar" | ||
assert activity.type_properties["value"][0]["value"].result == "is not null: 0" | ||
|
||
activity = next(activities) | ||
assert activity.name == "Set outputBoolVar" | ||
assert activity.type_properties["value"][0]["key"] == "outputBoolVar" | ||
assert activity.type_properties["value"][0]["value"].result == "is not null: False" | ||
|
||
activity = next(activities) | ||
assert activity.name == "Set outputArrayVar" | ||
assert activity.type_properties["value"][0]["key"] == "outputArrayVar" | ||
assert activity.type_properties["value"][0]["value"].result == "is not null: []" | ||
|
||
with pytest.raises(StopIteration): | ||
next(activities) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters