-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathTest.ps1
More file actions
40 lines (29 loc) · 1.42 KB
/
Test.ps1
File metadata and controls
40 lines (29 loc) · 1.42 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
$rootUrl = "http://localhost:7071"
$prefix = "table" # ef, memory, blob, table, cosmos
function Make-RestCall() {
-ContentType "application/json"
}
Write-Host "Testing with $prefix"
# add TODO item
$createModel = @{ TaskDescription="First task"}
$body = $createModel | ConvertTo-Json
Invoke-RestMethod -Uri "$rootUrl/api/$($prefix)todo" -Body $body -Method Post -ContentType "application/json"
$createModel = @{ TaskDescription="Second task"}
$body = $createModel | ConvertTo-Json
Invoke-RestMethod -Uri "$rootUrl/api/$($prefix)todo" -Body $body -Method Post -ContentType "application/json"
# get the TODO items
$items = Invoke-RestMethod -Uri "$rootUrl/api/$($prefix)todo" -Method Get
ForEach ($todo in $items) {
$taskId = $todo.Id
Write-Host "Updating $($todo.Id) - $($todo.TaskDescription)"
$updateModel = @{ IsCompleted=$true}
$body = $updateModel | ConvertTo-Json
Invoke-RestMethod -Uri "$rootUrl/api/$($prefix)todo/$($todo.id)" -Body $body -Method Put
Write-Host "Retrieving $($todo.Id) - $($todo.TaskDescription)"
Write-Host "URI: $rootUrl/api/$($prefix)todo/$($todo.id)"
Invoke-RestMethod -Uri "$rootUrl/api/$($prefix)todo/$($todo.id)" -Method Get
Write-Host "Deleting $($todo.Id) - $($todo.TaskDescription)"
Invoke-RestMethod -Uri "$rootUrl/api/$($prefix)todo/$($todo.id)" -Method Delete
}
Write-Host "Check they are all gone..."
Invoke-RestMethod -Uri "$rootUrl/api/$($prefix)todo" -Method Get