-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathPSResourceInfo.Tests.ps1
More file actions
47 lines (36 loc) · 2.06 KB
/
PSResourceInfo.Tests.ps1
File metadata and controls
47 lines (36 loc) · 2.06 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
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
Import-Module "$psscriptroot\PSGetTestUtils.psm1" -Force
Describe "Read PSGetModuleInfo xml file" -tags 'CI' {
BeforeAll {
$fileToRead = Join-Path -Path $PSScriptRoot -ChildPath "PSGetModuleInfo.xml"
}
It "Verifies expected error with null path" {
{ [Microsoft.PowerShell.PSResourceGet.UtilClasses.TestHooks]::ReadPSGetResourceInfo($null) } | Should -Throw -ErrorId 'PSInvalidOperationException'
}
It "Verifies expected error with invalid file path" {
{ [Microsoft.PowerShell.PSResourceGet.UtilClasses.TestHooks]::ReadPSGetResourceInfo('nonePath') } | Should -Throw -ErrorId 'PSInvalidOperationException'
}
It "Verifies PSGetModuleInfo.xml file is read successfully" {
$psGetInfo = [Microsoft.PowerShell.PSResourceGet.UtilClasses.TestHooks]::ReadPSGetResourceInfo($fileToRead)
CheckForExpectedPSGetInfo $psGetInfo
}
}
Describe "Write PSGetModuleInfo xml file" -tags 'CI' {
BeforeAll {
$fileToRead = Join-Path -Path $PSScriptRoot -ChildPath "PSGetModuleInfo.xml"
$fileToWrite = Join-Path -Path $TestDrive -ChildPath "PSGetModuleInfo_Write.xml"
}
It "Verifies expected error with null path" {
$psGetInfo = [Microsoft.PowerShell.PSResourceGet.UtilClasses.TestHooks]::ReadPSGetResourceInfo($fileToRead)
{ [Microsoft.PowerShell.PSResourceGet.UtilClasses.TestHooks]::WritePSGetResourceInfo($null, $psGetInfo) } | Should -Throw -ErrorId 'PSInvalidOperationException'
}
It "Verifies file write is successful" {
$psGetInfo = [Microsoft.PowerShell.PSResourceGet.UtilClasses.TestHooks]::ReadPSGetResourceInfo($fileToRead)
{ [Microsoft.PowerShell.PSResourceGet.UtilClasses.TestHooks]::WritePSGetResourceInfo($fileToWrite, $psGetInfo) } | Should -Not -Throw
}
It "Verifies written file can be read successfully" {
$newGetInfo = [Microsoft.PowerShell.PSResourceGet.UtilClasses.TestHooks]::ReadPSGetResourceInfo($fileToWrite)
CheckForExpectedPSGetInfo $newGetInfo
}
}