forked from OctopusDeploy/Library
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSet-OctopusStepTemplateProperty.Tests.ps1
More file actions
71 lines (61 loc) · 4.32 KB
/
Set-OctopusStepTemplateProperty.Tests.ps1
File metadata and controls
71 lines (61 loc) · 4.32 KB
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
$ErrorActionPreference = "Stop";
Set-StrictMode -Version "Latest";
. (Join-Path (Split-Path -Parent $MyInvocation.MyCommand.Path) "Test-JsonAssertions.ps1")
Describe "Set-OctopusStepTemplateProperty" {
It "Properties collection does not exist" {
$stepJson = ConvertFrom-Json -InputObject "{ }";
Set-OctopusStepTemplateProperty -StepJson $stepJson `
-PropertyName "Octopus.Action.Script.Syntax" `
-Value "PowerShell";
$expected = "{`r`n `"Properties`": {`r`n `"Octopus.Action.Script.Syntax`": `"PowerShell`"`r`n }`r`n}";
ConvertTo-OctopusJson -InputObject $stepJson | Should BeJsonEquivalent $expected
}
It "No properties exist" {
$stepJson = ConvertFrom-Json -InputObject "{ `"Properties`": { } }";
Set-OctopusStepTemplateProperty -StepJson $stepJson `
-PropertyName "Octopus.Action.Script.Syntax" `
-Value "PowerShell";
$expected = "{`r`n `"Properties`": {`r`n `"Octopus.Action.Script.Syntax`": `"PowerShell`"`r`n }`r`n}";
ConvertTo-OctopusJson -InputObject $stepJson | Should BeJsonEquivalent $expected
}
It "Specified property does not exist" {
$stepJson = ConvertFrom-Json -InputObject "{ `"Properties`": { `"otherProperty`": `"`" } }";
Set-OctopusStepTemplateProperty -StepJson $stepJson `
-PropertyName "Octopus.Action.Script.Syntax" `
-Value "PowerShell";
$expected = "{`r`n `"Properties`": {`r`n `"otherProperty`": `"`",`r`n `"Octopus.Action.Script.Syntax`": `"PowerShell`"`r`n }`r`n}";
ConvertTo-OctopusJson -InputObject $stepJson | Should BeJsonEquivalent $expected
}
It "Property does not exist" {
$stepJson = ConvertFrom-Json -InputObject "{ `"Properties`": { } }";
Set-OctopusStepTemplateProperty -StepJson $stepJson `
-PropertyName "Octopus.Action.Script.Syntax" `
-Value "PowerShell";
$expected = "{`r`n `"Properties`": {`r`n `"Octopus.Action.Script.Syntax`": `"PowerShell`"`r`n }`r`n}";
ConvertTo-OctopusJson -InputObject $stepJson | Should BeJsonEquivalent $expected
}
It "Property exists with a null value" {
$stepJson = ConvertFrom-Json -InputObject "{ `"Properties`": { `"Octopus.Action.Script.Syntax`" : null } }";
Set-OctopusStepTemplateProperty -StepJson $stepJson `
-PropertyName "Octopus.Action.Script.Syntax" `
-Value "PowerShell";
$expected = "{`r`n `"Properties`": {`r`n `"Octopus.Action.Script.Syntax`": `"PowerShell`"`r`n }`r`n}";
ConvertTo-OctopusJson -InputObject $stepJson | Should BeJsonEquivalent $expected
}
It "Property exists with an empty string value" {
$stepJson = ConvertFrom-Json -InputObject "{ `"Properties`": { `"Octopus.Action.Script.Syntax`" : `"`" } }";
Set-OctopusStepTemplateProperty -StepJson $stepJson `
-PropertyName "Octopus.Action.Script.Syntax" `
-Value "PowerShell";
$expected = "{`r`n `"Properties`": {`r`n `"Octopus.Action.Script.Syntax`": `"PowerShell`"`r`n }`r`n}";
ConvertTo-OctopusJson -InputObject $stepJson | Should BeJsonEquivalent $expected
}
It "Property exists with a string value" {
$stepJson = ConvertFrom-Json -InputObject "{ `"Properties`": { `"Octopus.Action.Script.Syntax`" : `"mySyntax`" } }";
Set-OctopusStepTemplateProperty -StepJson $stepJson `
-PropertyName "Octopus.Action.Script.Syntax" `
-Value "PowerShell";
$expected = "{`r`n `"Properties`": {`r`n `"Octopus.Action.Script.Syntax`": `"PowerShell`"`r`n }`r`n}";
ConvertTo-OctopusJson -InputObject $stepJson | Should BeJsonEquivalent $expected
}
}