{#- Once-per-suite mock-request-count helper (alef issue #443).
Context variables (see src/e2e/codegen/mock_assertions/helper.rs for the full contract):
- helper_name: function name
- total_path: mock server's total-count endpoint path
- one_path: mock server's single-key endpoint path
Emits ONE function using only the standard library (net/http, io, strconv, strings, fmt), so
it adds no new go.mod dependency. Callers build `pathAndQuery` from
"{{ total_path }}?prefix=<p>" (mock.requests.total) or "{{ one_path }}?key=<k>"
(mock.requests["<k>"]) -- see mock_assertions::model::MockQuery.
#}
func {{ helper_name }}(baseURL, pathAndQuery string) int {
resp, err := http.Get(baseURL + pathAndQuery)
if err != nil {
panic(fmt.Sprintf("{{ helper_name }}: request failed: %v", err))
}
defer resp.Body.Close()
raw, err := io.ReadAll(resp.Body)
if err != nil {
panic(fmt.Sprintf("{{ helper_name }}: read failed: %v", err))
}
n, err := strconv.Atoi(strings.TrimSpace(string(raw)))
if err != nil {
panic(fmt.Sprintf("{{ helper_name }}: non-integer response body %q: %v", string(raw), err))
}
return n
}