mirror of
https://github.com/benclaussen/NetboxPS.git
synced 2025-12-15 02:35:46 +00:00
Begin writing tests
This commit is contained in:
parent
8194acb5eb
commit
002feadb4a
4 changed files with 89 additions and 1 deletions
|
|
@ -39,7 +39,7 @@
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-DCIM_Support_ps1" ExportFunctions="False">Functions\DCIM\DCIM.Support.ps1</File>
|
<File Build="0" Shared="True" ReferenceFunction="Invoke-DCIM_Support_ps1" ExportFunctions="False">Functions\DCIM\DCIM.Support.ps1</File>
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-IPAM_Support_ps1" ExportFunctions="False">Functions\IPAM\IPAM.Support.ps1</File>
|
<File Build="0" Shared="True" ReferenceFunction="Invoke-IPAM_Support_ps1" ExportFunctions="False">Functions\IPAM\IPAM.Support.ps1</File>
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Virtualization_Support_ps1" ExportFunctions="False">Functions\Virtualization\Virtualization.Support.ps1</File>
|
<File Build="0" Shared="True" ReferenceFunction="Invoke-Virtualization_Support_ps1" ExportFunctions="False">Functions\Virtualization\Virtualization.Support.ps1</File>
|
||||||
<File Build="2" Shared="True" ReferenceFunction="Invoke-Setup_Support_ps1" ExportFunctions="False">Functions\Setup.Support.ps1</File>
|
<File Build="0" Shared="True" ReferenceFunction="Invoke-Setup_Support_ps1" ExportFunctions="False">Functions\Setup.Support.ps1</File>
|
||||||
</Files>
|
</Files>
|
||||||
<StartupScript>R:\Netbox\NetboxPS\Test-Module.ps1</StartupScript>
|
<StartupScript>R:\Netbox\NetboxPS\Test-Module.ps1</StartupScript>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -348,6 +348,41 @@ Describe -Name "IPAM tests" -Tag 'Ipam' -Fixture {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Context -Name "New-NetboxIPAMPrefix" -Fixture {
|
||||||
|
It "Should create a basic prefix" {
|
||||||
|
$Result = New-NetboxIPAMPrefix -Prefix "10.0.0.0/24"
|
||||||
|
|
||||||
|
Assert-VerifiableMock
|
||||||
|
|
||||||
|
$Result.Method | Should -Be 'POST'
|
||||||
|
$Result.URI | Should -Be 'https://netbox.domain.com/api/ipam/prefixes/'
|
||||||
|
$Result.Headers.Keys.Count | Should -BeExactly 1
|
||||||
|
$Result.Body | Should -Be '{"prefix":"10.0.0.0/24","status":1}'
|
||||||
|
}
|
||||||
|
|
||||||
|
It "Should create a prefix with a status and role names" {
|
||||||
|
$Result = New-NetboxIPAMPrefix -Prefix "10.0.0.0/24" -Status 'Active' -Role 'Active'
|
||||||
|
|
||||||
|
Assert-VerifiableMock
|
||||||
|
|
||||||
|
$Result.Method | Should -Be 'POST'
|
||||||
|
$Result.URI | Should -Be 'https://netbox.domain.com/api/ipam/prefixes/'
|
||||||
|
$Result.Headers.Keys.Count | Should -BeExactly 1
|
||||||
|
$Result.Body | Should -Be '{"prefix":"10.0.0.0/24","status":1,"role":"Active"}'
|
||||||
|
}
|
||||||
|
|
||||||
|
It "Should create a prefix with a status, role name, and tenant ID" {
|
||||||
|
$Result = New-NetboxIPAMPrefix -Prefix "10.0.0.0/24" -Status 'Active' -Role 'Active' -Tenant 15
|
||||||
|
|
||||||
|
Assert-VerifiableMock
|
||||||
|
|
||||||
|
$Result.Method | Should -Be 'POST'
|
||||||
|
$Result.URI | Should -Be 'https://netbox.domain.com/api/ipam/prefixes/'
|
||||||
|
$Result.Headers.Keys.Count | Should -BeExactly 1
|
||||||
|
$Result.Body | Should -Be '{"prefix":"10.0.0.0/24","status":1,"tenant":15,"role":"Active"}'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Context -Name "New-NetboxIPAMAddress" -Fixture {
|
Context -Name "New-NetboxIPAMAddress" -Fixture {
|
||||||
It "Should create a basic IP address" {
|
It "Should create a basic IP address" {
|
||||||
$Result = New-NetboxIPAMAddress -Address '10.0.0.1/24'
|
$Result = New-NetboxIPAMAddress -Address '10.0.0.1/24'
|
||||||
|
|
|
||||||
18
dist/Tests/Helpers.Tests.ps1
vendored
18
dist/Tests/Helpers.Tests.ps1
vendored
|
|
@ -146,6 +146,24 @@ Describe "Helpers tests" -Tag 'Core', 'Helpers' -Fixture {
|
||||||
$URIComponents.Parameters | Should -BeOfType [hashtable]
|
$URIComponents.Parameters | Should -BeOfType [hashtable]
|
||||||
$URIComponents.Parameters['q'] | Should -Be 'mytestquery'
|
$URIComponents.Parameters['q'] | Should -Be 'mytestquery'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
It "Should generate custom field parameters" {
|
||||||
|
$URIComponents = BuildURIComponents -URISegments @('segment1', 'segment2') -ParametersDictionary @{
|
||||||
|
'CustomFields' = @{
|
||||||
|
'PRTG_Id' = 1234
|
||||||
|
'Customer_Id' = 'abc'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$URIComponents | Should -BeOfType [hashtable]
|
||||||
|
$URIComponents.Keys.Count | Should -BeExactly 2
|
||||||
|
$URIComponents.Keys | Should -Be @("Segments", "Parameters")
|
||||||
|
$URIComponents.Segments | Should -Be @("segment1", "segment2")
|
||||||
|
$URIComponents.Parameters.Count | Should -BeExactly 2
|
||||||
|
$URIComponents.Parameters | Should -BeOfType [hashtable]
|
||||||
|
$URIComponents.Parameters['cf_prtg_id'] | Should -Be '1234'
|
||||||
|
$URIComponents.Parameters['cf_customer_id'] | Should -Be 'abc'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Context -Name "Invoking request tests" -Fixture {
|
Context -Name "Invoking request tests" -Fixture {
|
||||||
|
|
|
||||||
35
dist/Tests/IPAM.Tests.ps1
vendored
35
dist/Tests/IPAM.Tests.ps1
vendored
|
|
@ -348,6 +348,41 @@ Describe -Name "IPAM tests" -Tag 'Ipam' -Fixture {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Context -Name "New-NetboxIPAMPrefix" -Fixture {
|
||||||
|
It "Should create a basic prefix" {
|
||||||
|
$Result = New-NetboxIPAMPrefix -Prefix "10.0.0.0/24"
|
||||||
|
|
||||||
|
Assert-VerifiableMock
|
||||||
|
|
||||||
|
$Result.Method | Should -Be 'POST'
|
||||||
|
$Result.URI | Should -Be 'https://netbox.domain.com/api/ipam/prefixes/'
|
||||||
|
$Result.Headers.Keys.Count | Should -BeExactly 1
|
||||||
|
$Result.Body | Should -Be '{"prefix":"10.0.0.0/24","status":1}'
|
||||||
|
}
|
||||||
|
|
||||||
|
It "Should create a prefix with a status and role names" {
|
||||||
|
$Result = New-NetboxIPAMPrefix -Prefix "10.0.0.0/24" -Status 'Active' -Role 'Active'
|
||||||
|
|
||||||
|
Assert-VerifiableMock
|
||||||
|
|
||||||
|
$Result.Method | Should -Be 'POST'
|
||||||
|
$Result.URI | Should -Be 'https://netbox.domain.com/api/ipam/prefixes/'
|
||||||
|
$Result.Headers.Keys.Count | Should -BeExactly 1
|
||||||
|
$Result.Body | Should -Be '{"prefix":"10.0.0.0/24","status":1,"role":"Active"}'
|
||||||
|
}
|
||||||
|
|
||||||
|
It "Should create a prefix with a status, role name, and tenant ID" {
|
||||||
|
$Result = New-NetboxIPAMPrefix -Prefix "10.0.0.0/24" -Status 'Active' -Role 'Active' -Tenant 15
|
||||||
|
|
||||||
|
Assert-VerifiableMock
|
||||||
|
|
||||||
|
$Result.Method | Should -Be 'POST'
|
||||||
|
$Result.URI | Should -Be 'https://netbox.domain.com/api/ipam/prefixes/'
|
||||||
|
$Result.Headers.Keys.Count | Should -BeExactly 1
|
||||||
|
$Result.Body | Should -Be '{"prefix":"10.0.0.0/24","status":1,"tenant":15,"role":"Active"}'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Context -Name "New-NetboxIPAMAddress" -Fixture {
|
Context -Name "New-NetboxIPAMAddress" -Fixture {
|
||||||
It "Should create a basic IP address" {
|
It "Should create a basic IP address" {
|
||||||
$Result = New-NetboxIPAMAddress -Address '10.0.0.1/24'
|
$Result = New-NetboxIPAMAddress -Address '10.0.0.1/24'
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue