internal/tests/DynamicsBackend.tests.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
BeforeDiscovery {
    [hashtable[]] $backendCases = foreach ($vm in (Get-LabVm -Role DynamicsBackend))
    {
        @{vm = $vm }
    }
}

Describe "[$((Get-Lab).Name)] DynamicsBackend" -Tag DynamicsBackend {
    Context "Role deployment successful" {
        It "[DynamicsBackend] Should return the correct amount of machines" {
            (Get-LabVm -Role DynamicsBackend).Count | Should -Be $(Get-Lab).Machines.Where({$_.Roles.Name -contains 'DynamicsBackend'}).Count
        }
        
        It "<vm> should reach its Dynamics URL" -TestCases $backendCases {
        
            Invoke-LabCommand -ComputerName $vm -ScriptBlock {
                (Invoke-WebRequest -Method Get -Uri http://localhost:5555 -UseDefaultCredentials -UseBasicParsing -ErrorAction SilentlyContinue).StatusCode
            } -PassThru -NoDisplay | Should -Be 200
        }
    }
}