-
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.
feat: introduce TestFramework class to evaluate child executePipeline…
…Activities
- Loading branch information
Showing
21 changed files
with
400 additions
and
78 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
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
File renamed without changes.
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
51 changes: 51 additions & 0 deletions
51
src/AzureDataFactory.TestingFramework.Tests/Functional/Pipelines/Child/ChildPipelineTests.cs
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,51 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using AzureDataFactory.TestingFramework.Exceptions; | ||
using AzureDataFactory.TestingFramework.Models; | ||
using AzureDataFactory.TestingFramework.Models.Base; | ||
using AzureDataFactory.TestingFramework.Models.Pipelines; | ||
|
||
namespace AzureDataFactory.TestingFramework.Tests.Functional.Pipelines.Child; | ||
|
||
public class ChildPipelineTests | ||
{ | ||
[Fact] | ||
public void WhenExecutePipelineActivityIsCalled_ThenChildPipelineActivitiesAreExecuted() | ||
{ | ||
// Arrange | ||
var testFramework = new TestFramework(dataFactoryFolderPath: "Functional/Pipelines/Child", shouldEvaluateChildPipelines: true); | ||
var pipeline = testFramework.Repository.GetPipelineByName("main"); | ||
|
||
// Act | ||
var activities = testFramework.Evaluate(pipeline, new List<IRunParameter>() | ||
{ | ||
new RunParameter<string>(ParameterType.Parameter, "Url", "https://example.com"), | ||
new RunParameter<string>(ParameterType.Parameter, "Body", "{ \"key\": \"value\" }") | ||
}); | ||
|
||
// Assert | ||
var childWebActivity = activities.GetNext<WebActivity>(); | ||
Assert.Equal("API Call", childWebActivity.Name); | ||
Assert.Equal("https://example.com", childWebActivity.Uri); | ||
Assert.Equal("{ \"key\": \"value\" }", childWebActivity.Body); | ||
} | ||
|
||
[Fact] | ||
public void WhenExecutePipelineActivityIsCalledAndIsConfiguredToEvaluateChildPipelinesAndChildPipelineIsNotKnown_ThenExceptionShouldBeThrown() | ||
{ | ||
// Arrange | ||
var testFramework = new TestFramework(shouldEvaluateChildPipelines: true); | ||
var pipeline = PipelineFactory.ParseFromFile("Functional/Pipelines/Child/pipeline/main.json"); | ||
|
||
// Act | ||
var exception = Assert.Throws<PipelineNotFoundException>(() => testFramework.EvaluateAll(pipeline, new List<IRunParameter>() | ||
{ | ||
new RunParameter<string>(ParameterType.Parameter, "Url", "https://example.com"), | ||
new RunParameter<string>(ParameterType.Parameter, "Body", "{ \"key\": \"value\" }") | ||
})); | ||
|
||
// Assert | ||
Assert.Equal("Pipeline with name 'child' was not found in the repository. Make sure to load the repository before evaluating pipelines.", exception.Message); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/AzureDataFactory.TestingFramework.Tests/Functional/Pipelines/Child/pipeline/child.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,43 @@ | ||
{ | ||
"name": "child", | ||
"properties": { | ||
"activities": [ | ||
{ | ||
"name": "API Call", | ||
"type": "WebActivity", | ||
"dependsOn": [], | ||
"policy": { | ||
"timeout": "0.12:00:00", | ||
"retry": 0, | ||
"retryIntervalInSeconds": 30, | ||
"secureOutput": false, | ||
"secureInput": false | ||
}, | ||
"userProperties": [], | ||
"typeProperties": { | ||
"url": { | ||
"value": "@pipeline().parameters.Url", | ||
"type": "Expression" | ||
}, | ||
"method": "POST", | ||
"body": { | ||
"value": "@pipeline().parameters.Body", | ||
"type": "Expression" | ||
} | ||
} | ||
} | ||
], | ||
"parameters": { | ||
"Url": { | ||
"type": "string" | ||
}, | ||
"Body": { | ||
"type": "string" | ||
} | ||
}, | ||
"folder": { | ||
"name": "tests" | ||
}, | ||
"annotations": [] | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/AzureDataFactory.TestingFramework.Tests/Functional/Pipelines/Child/pipeline/main.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,42 @@ | ||
{ | ||
"name": "main", | ||
"properties": { | ||
"activities": [ | ||
{ | ||
"name": "Execute Child pipeline", | ||
"type": "ExecutePipeline", | ||
"dependsOn": [], | ||
"userProperties": [], | ||
"typeProperties": { | ||
"pipeline": { | ||
"referenceName": "child", | ||
"type": "PipelineReference" | ||
}, | ||
"waitOnCompletion": true, | ||
"parameters": { | ||
"Url": { | ||
"value": "@pipeline().parameters.Url", | ||
"type": "Expression" | ||
}, | ||
"Body": { | ||
"value": "@pipeline().parameters.Body", | ||
"type": "Expression" | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"parameters": { | ||
"Url": { | ||
"type": "string" | ||
}, | ||
"Body": { | ||
"type": "string" | ||
} | ||
}, | ||
"folder": { | ||
"name": "tests" | ||
}, | ||
"annotations": [] | ||
} | ||
} |
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
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
11 changes: 11 additions & 0 deletions
11
src/AzureDataFactory.TestingFramework/Exceptions/PipelineNotFoundException.cs
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,11 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
namespace AzureDataFactory.TestingFramework.Exceptions; | ||
|
||
public class PipelineNotFoundException : Exception | ||
{ | ||
public PipelineNotFoundException(string name) : base($"Pipeline with name '{name}' was not found in the repository. Make sure to load the repository before evaluating pipelines.") | ||
{ | ||
} | ||
} |
51 changes: 0 additions & 51 deletions
51
src/AzureDataFactory.TestingFramework/Models/Activities/Base/ActivitiesEvaluator.cs
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.