Pester checks

This commit is contained in:
Stephen Maunder 2017-11-18 21:06:20 +00:00
parent d28139a5bc
commit 47b174dfa0
10 changed files with 182 additions and 105 deletions

View file

@ -35,6 +35,11 @@ function Get-Asset()
function New-Asset()
{
[CmdletBinding(
SupportsShouldProcess=$true,
ConfirmImpact="High"
)]
Param(
[parameter(mandatory=$true)]
[string]$Name,
@ -64,16 +69,27 @@ function New-Asset()
$Body = $Values | ConvertTo-Json;
$result = Invoke-Method -URi "$url/api/v1/hardware" `
-Method POST `
-Body $Body `
-Token $apiKey
$Parameters = @{
Uri = "$url/api/v1/hardware"
Method = 'Post'
Body = $Body
Token = $apiKey
}
If ($PSCmdlet.ShouldProcess()) {
$result = Invoke-Method @Parameters
}
$result
}
function Set-Asset()
{
[CmdletBinding(
SupportsShouldProcess=$true,
ConfirmImpact="High"
)]
Param(
[parameter(mandatory=$true)]
[int]$id,
@ -105,16 +121,27 @@ function Set-Asset()
$Values += $customfields
$Body = $Values | ConvertTo-Json;
$result = Invoke-Method -URi "$url/api/v1/hardware/$id" `
-Method PUT `
-Body $Body `
-Token $apiKey
$Parameters = @{
Uri = "$url/api/v1/hardware/$id"
Method = 'Put'
Body = $Body
Token = $apiKey
}
If ($PSCmdlet.ShouldProcess()) {
$result = Invoke-Method @Parameters
}
$result
}
function Set-AssetOwner()
{
[CmdletBinding(
SupportsShouldProcess=$true,
ConfirmImpact="High"
)]
Param(
[parameter(mandatory=$true)]
[int]$id,
@ -135,10 +162,16 @@ function Set-AssetOwner()
$Body = $Values | ConvertTo-Json;
$result = Invoke-Method -Uri "$url/api/v1/hardware/$id/checkout" `
-Method POST `
-Token $apiKey `
-Body $Body
$Parameters = @{
Uri = "$url/api/v1/hardware/$id/checkout"
Method = 'POST'
Body = $Body
Token = $apiKey
}
If ($PSCmdlet.ShouldProcess()) {
$result = Invoke-Method @Parameters
}
return $result
}

View file

@ -1,4 +1,4 @@
function Get-Categories()
function Get-Category()
{
Param(
[parameter(mandatory=$true)]

View file

@ -17,6 +17,11 @@ function Get-Component()
function New-Component()
{
[CmdletBinding(
SupportsShouldProcess=$true,
ConfirmImpact="High"
)]
Param(
[parameter(mandatory=$true)]
[string]$name,
@ -42,16 +47,27 @@ function New-Component()
$Body = $Values | ConvertTo-Json;
$result = Invoke-Method -URi "$url/api/v1/components" `
-Method POST `
-Body $Body `
-Token $apiKey
$Parameters = @{
Uri = "$url/api/v1/components"
Method = 'POST'
Body = $Body
Token = $apiKey
}
If ($PSCmdlet.ShouldProcess()) {
$result = Invoke-Method @Parameters
}
$result
}
function Update-Component()
function Set-Component()
{
[CmdletBinding(
SupportsShouldProcess=$true,
ConfirmImpact="High"
)]
Param(
[parameter(mandatory=$true)]
[string]$id,
@ -72,10 +88,16 @@ function Update-Component()
$Body = $Values | ConvertTo-Json;
$result = Invoke-Method -URi "$url/api/v1/components/$component_id" `
-Method Patch `
-Body $Body `
-Token $apiKey
$Parameters = @{
Uri = "$url/api/v1/components/$component_id"
Method = 'Patch'
Body = $Body
Token = $apiKey
}
If ($PSCmdlet.ShouldProcess()) {
$result = Invoke-Method @Parameters
}
$result
}

View file

@ -1,4 +1,4 @@
function Get-Manufacturers()
function Get-Manufacturer()
{
Param(
[parameter(mandatory=$true)]
@ -17,6 +17,11 @@ function Get-Manufacturers()
function New-Manufacturer()
{
[CmdletBinding(
SupportsShouldProcess=$true,
ConfirmImpact="High"
)]
Param(
[parameter(mandatory=$true)]
[string]$Name,
@ -36,10 +41,16 @@ function New-Manufacturer()
#Convert Values to JSON format
$Body = $Values | ConvertTo-Json;
$result = Invoke-Method -URi "$url/api/v1/manufacturers" `
-Method POST `
-Body $Body `
-Token $apiKey
$Parameters = @{
Uri = "$url/api/v1/manufacturers"
Method = 'post'
Body = $Body
Token = $apiKey
}
If ($PSCmdlet.ShouldProcess()) {
$result = Invoke-Method @Parameters
}
$result
}

View file

@ -1,5 +1,5 @@
function Get-Models()
function Get-Model()
{
Param(
[parameter(mandatory=$true)]
@ -19,6 +19,11 @@ function Get-Models()
function New-Model()
{
[CmdletBinding(
SupportsShouldProcess=$true,
ConfirmImpact="High"
)]
Param(
[parameter(mandatory=$true)]
[string]$name,
@ -48,10 +53,16 @@ function New-Model()
$Body = $Values | ConvertTo-Json;
$result = Invoke-Method -URi "$url/api/v1/models" `
-Method POST `
-Body $Body `
-Token $apiKey
$Parameters = @{
Uri = "$url/api/v1/models"
Method = 'post'
Body = $Body
Token = $apiKey
}
If ($PSCmdlet.ShouldProcess()) {
$result = Invoke-Method @Parameters
}
$result
}

View file

@ -15,7 +15,7 @@ Get-Users -url "https://assets.dip.co.uk" -token "token..."
Get-Users -url "https://assets.dip.co.uk" -token "token..." | Where-Object {$_.username -eq "stephenm" }
#>
function Get-Users()
function Get-User()
{
Param(
[parameter(mandatory=$true)]

Binary file not shown.

View file

@ -63,7 +63,7 @@ Describe "SnipeitPS" {
$script:manifest = Invoke-Expression (Get-Content $script:manifestFile -Raw)
It "Manifest file includes the correct root module" {
$script:manifest.RootModule | Should Be 'SnipeitPS.psm1'
$script:manifest.RootModule | Should Be 'SnipeitPS'
}
It "Manifest file includes the correct guid" {