@@ -8,6 +8,13 @@ Describe "Invoke-RestMethodWithProgress" -Tag InvokeRestMethodWithProgress {
8
8
9
9
BeforeEach {
10
10
Reset-APIEstimatedResponseTimes
11
+ Push-Location - StackName " MOCK-IRMWP" - Path $PSScriptRoot
12
+ New-PSDrive - Name " MOCK-IRMWP" - PSProvider " FileSystem" - Root $PSScriptRoot
13
+ }
14
+
15
+ AfterEach {
16
+ Pop-Location - StackName " MOCK-IRMWP" - ErrorAction " SilentlyContinue"
17
+ Remove-PSDrive - Name " MOCK-IRMWP" - ErrorAction " SilentlyContinue"
11
18
}
12
19
13
20
It " should return the known response if the API call is successful" {
@@ -31,6 +38,51 @@ Describe "Invoke-RestMethodWithProgress" -Tag InvokeRestMethodWithProgress {
31
38
$response | Should - BeExactly " a happy web response from a web server"
32
39
}
33
40
41
+ It " should work when run from a psdrive" {
42
+
43
+ Mock Start-Job {
44
+ return & $script :StartJobCommand { }
45
+ }
46
+
47
+ Mock Receive-Job {
48
+ return @ {
49
+ Response = " a happy web response from a web server"
50
+ }
51
+ }
52
+
53
+ $params = @ {
54
+ " Method" = " GET" ;
55
+ " Uri" = " http://localhost" ;
56
+ }
57
+
58
+ Set-Location " MOCK-IRMWP:\"
59
+
60
+ $response = Invoke-RestMethodWithProgress - Params $params
61
+ $response | Should - BeExactly " a happy web response from a web server"
62
+ }
63
+
64
+ It " should work when run from a non-filesystem provider" {
65
+
66
+ Mock Invoke-RestMethod {
67
+ return " a happy web response from a web server"
68
+ }
69
+
70
+ Mock Start-Job { }
71
+
72
+ $params = @ {
73
+ " Method" = " GET" ;
74
+ " Uri" = " http://localhost" ;
75
+ }
76
+
77
+ Push-Location - StackName " MOCK-IRMWP"
78
+ Set-Location " Env:\"
79
+
80
+ $response = Invoke-RestMethodWithProgress - Params $params
81
+ $response | Should - BeExactly " a happy web response from a web server"
82
+ Should - Invoke - CommandName Invoke-RestMethod - Times 1
83
+ Should - Invoke - CommandName Start-Job - Times 0
84
+ }
85
+
34
86
It " should throw if the API call fails" {
35
87
36
88
$params = @ {
0 commit comments