Documentation
¶
Index ¶
- func MarshalJSONLine(r Result) ([]byte, error)
- func WriteHTML(dir string, results []*engine.UnitResult, redact func(string) string) error
- func WriteJSON(dir string, results []*engine.UnitResult, redact func(string) string) error
- func WriteJUnit(path string, results []*engine.UnitResult, redact func(string) string) error
- func WriteTAP(path string, results []*engine.UnitResult, redact func(string) string) error
- type Assert
- type BodyStore
- type Call
- type Capture
- type Certificate
- type Contract
- type Cookie
- type Entry
- type EntrySonde
- type Iteration
- type NameValue
- type Request
- type Response
- type ResponseCookie
- type Result
- type Sonde
- type Timings
- type Violation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalJSONLine ¶
MarshalJSONLine encodes r the way `--json`/`--report-json` do: one compact JSON value, HTML escaping turned off (so `<`, `>` and `&` are written as-is, matching the reference serializer).
func WriteHTML ¶
WriteHTML appends one page per result, in order, to the HTML report at dir: a page per file under dir/store/<id>.html — one directory level under dir, a flat file rather than a nested index.html, so a shell glob like "dir/**/*.html" (which without bash's globstar only ever descends one extra level) still finds it (source and calls are escaped through html/template, so a hostile header, URL or body value can never break out of its context) — and a dir/index.html listing every run recorded so far, linking to its page.
Repeated calls with the same dir read the report's manifest and grow it — the report is cumulative across invocations, matching the other report formats. redact masks secret values everywhere a string is written.
func WriteJSON ¶
WriteJSON appends one Result per result, in order, to the JSON report at dir/report.json, saving every call's response body, redacted, under dir/store/<id>_response<ext> and referencing it from the corresponding Response.Body as "store/<file>" (relative to report.json). ext is ".json", ".xml" or ".html" for a response of that content type, and omitted otherwise.
Repeated calls with the same dir read the existing report.json (if any) and extend its array — the report is cumulative across invocations, matching the reference CLI. Existing entries are kept as raw JSON and spliced back in unparsed, so a rewrite never loses a big integer's precision, an object's member order, or a field this package's Result does not know about (fields written by another tool, or the reserved "sonde" key) — only the entries this call adds are ever actually decoded/re-encoded. The file is written atomically (temp file + rename), so a run killed mid-write never leaves a truncated report for the next invocation to choke on. redact masks secret values everywhere a string (including a response body) is written.
func WriteJUnit ¶
WriteJUnit appends one <testsuite> summarizing results, in the given order, to the JUnit report at path: one <testcase> per result, holding a <failure> per assert error and an <error> per runtime error (grouped, failures first). A run that produced no error is a self-closed, empty <testcase> — except a file that never parsed (ParseError set) or a unit stopped before its last entry (Interrupted, with no error of its own to show for it): both would otherwise look like a pass, so each gets a synthetic <error> instead.
Repeated calls with the same path grow the root <testsuites> element by one more <testsuite>, leaving every earlier one untouched — the report is cumulative across invocations, matching the reference CLI. redact masks secret values in every rendered failure/error message. The file is written atomically (temp file + rename), so a run killed mid-write never leaves a truncated report for the next invocation to choke on.
func WriteTAP ¶
WriteTAP appends one line per result, in order, to the TAP report at path, renumbering the whole file: repeated calls with the same path read every line already there, then rewrite the file with the old lines followed by the new ones, all under a single "1..N" plan — matching the reference CLI's cumulative behavior. redact masks secret values in the file name each line reports. The file is written atomically (temp file + rename), so a run killed mid-write never leaves a truncated report for the next invocation to choke on.
Types ¶
type Assert ¶
type Assert struct {
Line int `json:"line"`
Message string `json:"message,omitempty"`
Success bool `json:"success"`
}
Assert is the outcome of one assert (implicit or explicit).
type BodyStore ¶
BodyStore saves an HTTP response body (as transferred, before content decoding) and returns the path the JSON report should reference for it (e.g. "store/<id>_response.json"). contentType is the response's Content-Type header value, used to pick a file extension.
Passed to JSON only by --report-json (internal/report's WriteJSON); --json (one line, no report directory) always passes a nil store, and every Response.Body is then left empty.
type Call ¶
type Call struct {
Request Request `json:"request"`
Response Response `json:"response"`
Timings Timings `json:"timings"`
}
Call is one HTTP exchange (redirects produce several per entry).
type Certificate ¶
type Certificate struct {
ExpireDate string `json:"expire_date,omitempty"`
Issuer string `json:"issuer,omitempty"`
SerialNumber string `json:"serial_number,omitempty"`
StartDate string `json:"start_date,omitempty"`
Subject string `json:"subject,omitempty"`
SubjectAltName string `json:"subject_alt_name,omitempty"`
Value string `json:"value,omitempty"`
}
Certificate is the server certificate of an HTTPS response; dates are "2006-01-02 15:04:05 UTC" and the value is PEM.
type Contract ¶
type Contract struct {
Violations []Violation `json:"violations"`
}
Contract holds the contract findings of an attempt's final response.
type Cookie ¶
type Cookie struct {
Domain string `json:"domain"`
Expires int64 `json:"expires"`
HTTPS bool `json:"https"`
IncludeSubdomain bool `json:"include_subdomain"`
Name string `json:"name"`
Path string `json:"path"`
Value string `json:"value"`
}
Cookie is one entry of the cookie store at the end of a run.
type Entry ¶
type Entry struct {
Asserts []Assert `json:"asserts"`
Calls []Call `json:"calls"`
Captures []Capture `json:"captures"`
CurlCmd string `json:"curl_cmd"`
Index int `json:"index"`
Line int `json:"line"`
// Sonde holds data without an upstream equivalent; absent otherwise.
Sonde *EntrySonde `json:"sonde,omitempty"`
Time int64 `json:"time"` // milliseconds
}
Entry is one attempt of an entry (one per retry, one per repetition).
type EntrySonde ¶
type EntrySonde struct {
Contract *Contract `json:"contract,omitempty"`
}
EntrySonde is the `sonde` object of an entry.
type Iteration ¶
type Iteration struct {
Row int `json:"row"` // 1-based
}
Iteration identifies the data row a file ran with (`--data`).
type Request ¶
type Request struct {
Cookies []NameValue `json:"cookies"`
Headers []NameValue `json:"headers"`
Method string `json:"method"`
QueryString []NameValue `json:"query_string"`
URL string `json:"url"`
}
Request is the request side of a Call.
type Response ¶
type Response struct {
Body string `json:"body,omitempty"`
Certificate *Certificate `json:"certificate,omitempty"`
Cookies []ResponseCookie `json:"cookies"`
Headers []NameValue `json:"headers"`
HTTPVersion string `json:"http_version"`
Status int `json:"status"`
}
Response is the response side of a Call. Body is empty for `--json` (single line, no report directory to store bodies in) and a "store/<file>" reference for `--report-json` (set by BodyStore). Field order is alphabetical by JSON key, matching the reference serializer (see Result's doc comment) — "body" sorts before "cookies".
type ResponseCookie ¶
type ResponseCookie struct {
Domain string `json:"domain,omitempty"`
Expires string `json:"expires,omitempty"`
HTTPOnly bool `json:"httponly,omitempty"`
MaxAge string `json:"max_age,omitempty"`
Name string `json:"name"`
Path string `json:"path,omitempty"`
SameSite string `json:"same_site,omitempty"`
Secure bool `json:"secure,omitempty"`
Value string `json:"value"`
}
ResponseCookie is a Set-Cookie header, parsed into its attributes. A boolean attribute (secure, httponly) is Rust's `Option<bool>`: it is either true or entirely absent, so a plain bool with omitempty matches it exactly. max_age is a decimal string, not a number (the reference struct keeps it as `Option<String>`, "maybe ... should be u64" per its own comment).
type Result ¶
type Result struct {
Cookies []Cookie `json:"cookies"`
Entries []Entry `json:"entries"`
Filename string `json:"filename"`
// Sonde holds data without an upstream equivalent; absent otherwise.
Sonde *Sonde `json:"sonde,omitempty"`
Success bool `json:"success"`
Time int64 `json:"time"` // milliseconds
}
Result is one file's JSON result: the schema shared by `--json` and `--report-json` (docs/report-json.md). Field names, order and nesting reproduce the upstream 8.0.1 JSON export byte-for-byte (verified against testdata/conformance/hurl/tests_ok/json_output and tests_failed/assert_value_error): every struct's JSON keys are declared in the alphabetical order the reference serializer produces.
type Sonde ¶
type Sonde struct {
Iteration *Iteration `json:"iteration,omitempty"`
}
Sonde is the `sonde` object of a result.
type Timings ¶
type Timings struct {
AppConnect int64 `json:"app_connect"`
BeginCall string `json:"begin_call"`
Connect int64 `json:"connect"`
EndCall string `json:"end_call"`
NameLookup int64 `json:"name_lookup"`
PreTransfer int64 `json:"pre_transfer"`
StartTransfer int64 `json:"start_transfer"`
Total int64 `json:"total"`
}
Timings are the phases of a transfer, in milliseconds (except the two timestamps).
type Violation ¶
type Violation struct {
InstancePath string `json:"instance_path,omitempty"`
Kind string `json:"kind"`
Message string `json:"message"`
Operation string `json:"operation,omitempty"`
SpecPointer string `json:"spec_pointer,omitempty"`
Warning bool `json:"warning,omitempty"`
}
Violation is a response not conforming to the contract (--openapi).