forked from microsoft/AL-Go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWorkflowInitialize.Test.ps1
130 lines (113 loc) · 5.28 KB
/
WorkflowInitialize.Test.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
Get-Module TestActionsHelper | Remove-Module -Force
Import-Module (Join-Path $PSScriptRoot 'TestActionsHelper.psm1')
$errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0
Describe "WorkflowInitialize Action Tests" {
BeforeAll {
$actionName = "WorkflowInitialize"
$scriptRoot = Join-Path $PSScriptRoot "..\Actions\$actionName" -Resolve
$scriptName = "$actionName.ps1"
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', 'scriptPath', Justification = 'False positive.')]
$scriptPath = Join-Path $scriptRoot $scriptName
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', 'actionScript', Justification = 'False positive.')]
$actionScript = GetActionScript -scriptRoot $scriptRoot -scriptName $scriptName
}
It 'Compile Action' {
Invoke-Expression $actionScript
}
It 'Test action.yaml matches script' {
$permissions = [ordered]@{
}
$outputs = [ordered]@{
"telemetryScopeJson" = "A telemetryScope that covers the workflow"
}
YamlTest -scriptRoot $scriptRoot -actionName $actionName -actionScript $actionScript -permissions $permissions -outputs $outputs
}
It 'Test Test-AL-Go-Repository' {
function TestSettingsFiles {
Param(
[string]$ALGoOrgSettings,
[string]$ALGoRepoSettings,
[string]$repoSettings,
[string]$projectSettings,
[string]$project1Settings
)
$tempDir = Join-Path ([System.IO.Path]::GetTempPath()) ([GUID]::NewGuid().ToString())
New-Item -Path $tempDir -ItemType Directory | Out-Null
try {
$githubFolder = Join-Path $tempDir '.github'
New-Item -Path $githubFolder -ItemType Directory | Out-Null
$ALGoFolder = Join-Path $tempDir '.AL-Go'
New-Item -Path $ALGoFolder -ItemType Directory | Out-Null
$Project1ALGoFolder = Join-Path $tempDir 'Project1/.AL-Go'
New-Item -Path $Project1ALGoFolder -ItemType Directory | Out-Null
$ENV:ALGoOrgSettings = $ALGoOrgSettings
$ENV:ALGoRepoSettings = $ALGoRepoSettings
Set-Content -Path (Join-Path $githubFolder 'AL-Go-Settings.json') -Value $repoSettings -Encoding UTF8
Set-Content -Path (Join-Path $ALGoFolder 'settings.json') -Value $projectSettings -Encoding UTF8
Set-Content -Path (Join-Path $Project1ALGoFolder 'settings.json') -Value $project1Settings -Encoding UTF8
TestALGoRepository -baseFolder $tempDir
}
finally {
Remove-Item -Path $tempDir -Recurse -Force
}
}
. (Join-Path $PSScriptRoot "..\Actions\AL-Go-Helper.ps1" -Resolve)
. (Join-Path $PSScriptRoot "..\Actions\AL-Go-TestRepoHelper.ps1" -Resolve)
Mock Write-Host { }
Mock OutputError { throw $message }
TestSettingsFiles `
-ALGoOrgSettings '{}' `
-ALGoRepoSettings '{}' `
-repoSettings '{}' `
-projectSettings '{}' `
-project1Settings '{}'
TestSettingsFiles `
-ALGoOrgSettings '{}' `
-ALGoRepoSettings '{}' `
-repoSettings '{"templateUrl":"https://github.com/microsoft/AL-Go-PTE@latest"}' `
-projectSettings '{}' `
-project1Settings '{}'
TestSettingsFiles `
-ALGoOrgSettings '{"templateUrl":"https://github.com/microsoft/AL-Go-PTE@latest"}' `
-ALGoRepoSettings '{}' `
-repoSettings '{}' `
-projectSettings '{}' `
-project1Settings '{}'
{TestSettingsFiles `
-ALGoOrgSettings ' {}' `
-ALGoRepoSettings '{}' `
-repoSettings '{}' `
-projectSettings '{}' `
-project1Settings '{}' }| Should -Throw
{TestSettingsFiles `
-ALGoOrgSettings '{}' `
-ALGoRepoSettings ' {}' `
-repoSettings '{}' `
-projectSettings '{}' `
-project1Settings '{}' }| Should -Throw
{TestSettingsFiles `
-ALGoOrgSettings '{}' `
-ALGoRepoSettings '{}' `
-repoSettings ' {}' `
-projectSettings '{}' `
-project1Settings '{}' }| Should -Throw
{TestSettingsFiles `
-ALGoOrgSettings '{}' `
-ALGoRepoSettings '{}' `
-repoSettings '{}' `
-projectSettings ' {}' `
-project1Settings '{}' }| Should -Throw
{TestSettingsFiles `
-ALGoOrgSettings '{}' `
-ALGoRepoSettings '{}' `
-repoSettings '{}' `
-projectSettings '{}' `
-project1Settings ' {}' }| Should -Throw
{TestSettingsFiles `
-ALGoOrgSettings '{}' `
-ALGoRepoSettings '{}' `
-repoSettings '{}' `
-projectSettings '{"templateUrl":"https://github.com/microsoft/AL-Go-PTE@latest"}' `
-project1Settings '{}' }| Should -Throw
}
}