Start-IpsGcpPrepareAndPublishJob.Tests.ps1
BeforeAll { . $PSScriptRoot\Start-IpsGcpPrepareAndPublishJob.ps1 . $PSScriptRoot\JobParamMethods.ps1 . $PSScriptRoot\PlatformMethods.ps1 . $PSScriptRoot\PrepareMethods.ps1 . $PSScriptRoot\Auth.ps1 . $PSScriptRoot\Log.ps1 . $PSScriptRoot\VersionCheck.ps1 } Describe 'Test parameter handling' { It 'Test config file' { Mock Add-PSSnapin { } Mock AuthToCitrixCloud {return @{}} Mock VersionCheck { } Mock Invoke-CCRestMethod { $Global:RestBody = $json; $Global:RestQuery = $query } $config = @' { "Deployment": "api.test.layering.cloudburrito.com", "CustomerId": "wse2edev", "CloudPlatform": "gcp", "CloudCwSecretId": "nightly-gcp-1", "CloudProvisioningType": "Mcs", "CloudDiskName": "nightly-mia-win10", "XdReconfigure": [ {"ParameterName": "controllers", "ParameterValue": "cloudy-cc1.wse2edev.cloudy"}, {"ParameterName": "portnumber", "ParameterValue": "80"} ], "PrepareResourceLocationId": "52509414-3c19-4a8e-a711-01837da5a1c8", "PublishSmb": { "Host": "10.0.1.212", "Share": "Files", "DiskName": "nightly-mia", "DiskFormat": "VhdxDiskFormat", "CwId": "test-cloudy" }, "GcpZone": "us-east4-a", "VpcNetworkName": "cloudy-ce", "VpcNetworkSubnetName": "regions/us-east4/subnetworks/cloudy-ce-us-east4", "NetworkTags": ["cloudy"] } '@ $configFile = New-TemporaryFile $config | Set-Content -Path $configFile.FullName Start-IpsGcpPrepareAndPublishJob -ConfigJsonFile $configFile.FullName $body = ConvertFrom-Json $restBody Write-Host $restBody $restQuery.dryRun | Should -Be $false $body.provisioningType | Should -Be "Mcs" $body.platformCredentialId | Should -Be "nightly-gcp-1" $body.resourceLocationId | Should -Be "52509414-3c19-4a8e-a711-01837da5a1c8" $body.targetImageName | Should -Be "nightly-mia-win10" $body.outputImageFilename | Should -Be "nightly-mia" $body.outputStorageLocation.location | Should -Be "smb://10.0.1.212/Files/" $body.outputStorageLocation.credentialId | Should -Be "test-cloudy" $body.xdReconfigure -is [Array] | Should -Be $true $body.xdReconfigure | Should -HaveCount 2 $body.xdReconfigure[0].ParameterName | Should -Be "controllers" $body.xdReconfigure[0].ParameterValue | Should -Be "cloudy-cc1.wse2edev.cloudy" $body.xdReconfigure[1].ParameterName | Should -Be "portnumber" $body.xdReconfigure[1].ParameterValue | Should -Be "80" $body.networkTags -is [Array] | Should -Be $true $body.networkTags | Should -HaveCount 1 $body.networkTags[0] | Should -Be "cloudy" $tags = Convert-Object $body.tags $tags.Count | Should -Be 1 $tags.ContainsKey("ctx-user") | Should -Be $true } } |