Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Hunt committed Oct 23, 2023
1 parent e5d5957 commit 6aa2e74
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
18 changes: 6 additions & 12 deletions example.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
[[plan]]
label = "google"
url = "https://google.com"
code = 200

[[plan]]
label = "google"
url = "https://google.com"
code = "moved"

[[plan]]
label = "google"
url = "https://www.google.com/"
url = "http://www.google.com"
code = "ok"
tags = ["demo"]

# Verify that this URL returns text that matches "some regex":
[[plan]]
label = "api"
url = "http://api.example.com/"
tags = ["demo", "regex"]
text = "API for example.com"
regex = "some regex"

Expand All @@ -25,4 +18,5 @@
label = "redirect"
url = "https://example.com/redirect"
ips = ["*", "10.11.22.33", "10.99.88.77"]
code = 301
code = 301
tags = ["demo", "ips"]
30 changes: 20 additions & 10 deletions src/Invoke-HttpUnit.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,44 +22,54 @@ function Invoke-HttpUnit {
.PARAMETER Certificate
For http/https, specifies the client certificate that is used for a secure web request. Enter a variable that contains a certificate.
.EXAMPLE
PS > Invoke-HttpUnit -Url https://google.com -Code 200
PS > Invoke-HttpUnit -Url https://www.google.com -Code 200
Label : https://www.google.com/
Result :
Connected : True
GotCode : True
GotText : False
GotRegex : False
GotHeaders : False
InvalidCert : False
TimeTotal : 00:00:06.3031178
.EXAMPLE
PS > Invoke-HttpUnit -Path .\example.toml
TimeTotal : 00:00:00.4695217
.EXAMPLE
PS > Invoke-HttpUnit -Path .\example.toml
Label : google
Result :
Connected : True
GotCode : True
GotText : False
GotRegex : False
GotHeaders : False
InvalidCert : False
TimeTotal : 00:00:05.9053511
TimeTotal : 00:00:00.3210709
Result : Exception calling "Send" with "1" argument(s): "No such host is known. (api.example.com:80)"
Label : api
Result : Exception calling "GetResult" with "0" argument(s): "No such host is known. (api.example.com:80)"
Connected : False
GotCode : False
GotText : False
GotRegex : False
GotHeaders : False
InvalidCert : False
TimeTotal : 00:00:00.0539084
TimeTotal : 00:00:00.0280893
Result :
Label : redirect
Result : Unexpected status code: NotFound
Connected : True
GotCode : True
GotCode : False
GotText : False
GotRegex : False
GotHeaders : False
InvalidCert : False
TimeTotal : 00:00:00.1334766
TimeTotal : 00:00:00.1021738
.NOTES
A $null Results property signifies no error and all specified
test criteria passed.
You can use the common variable -OutVariable to save the test results. Each TestResult object has a hidden Response property with the raw response from the server.
.LINK
https://github.com/StackExchange/httpunit
#>
Expand Down

0 comments on commit 6aa2e74

Please sign in to comment.