gateway: TestSearchAPIFailureKeepsNoURL's query has no number a port can hold (#5616)

Fixes #5616

Ubuntu CI run 42368406605 failed it: "the query's "4410" is in
usage.jsonl", where the only 4410 was the fake server's random port,
host 127.0.0.1:44105. The row rightly logs the host, so a query word
made of digits matches the port now and then. The query is letters
only now, as 4a4a82cd4 did for the sibling TestSearchAPIAsksAreLogged;
the check that no query word reaches usage.jsonl is unchanged, and the
new word still rides in the GET URL, so a leaked URL still fails it.

Test-only; no gateway code changes.

Broken by hand: the untouched test with the fake server's listener
pinned to 127.0.0.1:44105 (throwaway harness, not committed) fails with
the CI message: the query's "4410" is in usage.jsonl. With this change
and the same pin it passes.

Run at this tree (origin/main 56f095604 + this):
go test -tags nogui -race -count=20 -run 'TestSearchAPI|TestOwnSearchIsLogged' ./internal/gateway ok.
GOOS=linux go vet -tags nogui ./internal/gateway and
GOOS=windows go vet ./internal/gateway clean; gofmt -l and
git diff --check clean. Not run: the whole gateway package (one-line
test literal change).
This commit is contained in:
Gaoshou101
2026-11-10 15:53:24 +08:00
committed by yetone
parent 6fa9ff8358
commit 17b9b5b031
+3 -1
View File
@@ -123,7 +123,9 @@ func TestSearchAPIAsksAreLogged(t *testing.T) {
// errors say whole: the row says the host and what went wrong, not the URL.
func TestSearchAPIFailureKeepsNoURL(t *testing.T) {
fresh(t)
const query = "wombat lattice 4410"
// letters only: a number could be in the server's random port
// (127.0.0.1:44105 held "4410" on ubuntu CI, #5616)
const query = "wombat lattice numbatzor"
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
c, _, err := w.(http.Hijacker).Hijack()
if err == nil {